Ticket #2390: changeset.php

File changeset.php, 2.1 KB (added by woidrick, 10 years ago)

hack, sorry, cant use diff

Line 
1<?php
2
3include_once('tagged.php');
4include_once('canonical.php');
5
6class changeset extends tagged {
7
8  /* constructor */ function changeset($id, $amended=FALSE) { 
9    if (! $amended) { $id = canonical::getuniqueid($id, 'changeset'); }
10    $this->id = $id;
11  } 
12
13  // --------------------------------------------------
14  function set_latlon($lat, $lon) {
15    $this->lat = $lat;
16    $this->lon = $lon;
17  }
18
19  // --------------------------------------------------
20  /* a node has its own natural lat/lon so no calculation needed in this subclass */
21  function calc_latlong() { return TRUE; }
22
23  // --------------------------------------------------
24  function insert() {
25    global $db, $added;
26    $db->insert($this);
27    $added['changeset']++;
28  }
29
30  // --------------------------------------------------
31  function delete() {
32    global $db;
33    $changeset = new changeset($this->id, TRUE);
34    $db->delete($changeset, 'id');
35  }
36
37  // --------------------------------------------------
38/*  function parent_ids() {
39    global $db;
40    $parent_ids = array();
41
42    // parent ways
43    $q = $db->query();
44    $way_node = new way_node();
45    $way_node->node_id = $this->id;
46    $way = new way(0, TRUE);
47    while ($q->select($way_node) > 0) {
48      $way->id = $way_node->way_id;
49      $parent_ids[] = $way->id;
50      $way_parent_ids = $way->parent_ids();
51      if (! empty($way_parent_ids)) {
52        $parent_ids = array_merge($parent_ids, $way_parent_ids);
53      }
54    }
55
56    // and then parent relations
57    $q = $db->query();
58    $relation_node = new relation_node();
59    $relation_node->node_id = $this->id;
60    $relation = new relation(0, TRUE);
61    while ($q->select($relation_node) > 0) {
62      $relation->id = $relation_node->relation_id;
63      $parent_ids[] = $relation->id;
64      $relation_parent_ids = $relation->parent_ids();
65      if (! empty($relation_parent_ids)) {
66        $parent_ids = array_merge($parent_ids, $relation_parent_ids);
67      }
68    }
69
70    // finally, consolidate
71    $parent_ids = array_unique($parent_ids);
72    return $parent_ids;
73  }
74*/
75}
76
77?>