Index: trunk/extensions/gis/neighbors.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | var $p; |
39 | 39 | var $d; |
40 | 40 | var $title; |
| 41 | + var $attr; |
41 | 42 | |
42 | 43 | function neighbors( $coor, $dist, $title ) |
43 | 44 | { |
— | — | @@ -44,6 +45,7 @@ |
45 | 46 | $this->d = $dist; |
46 | 47 | if ($this->d <= 0) $this->d = 1000; /* default to 1000 km */ |
47 | 48 | $this->title = $title; |
| 49 | + $this->attr = $this->p->get_attr(); |
48 | 50 | } |
49 | 51 | |
50 | 52 | function show() |
— | — | @@ -72,7 +74,8 @@ |
73 | 75 | $lon0 = $this->p->londeg; |
74 | 76 | |
75 | 77 | $g = new gis_database(); |
76 | | - $g->select_radius_m( $lat0, $lon0, $this->d * 1000); |
| 78 | + $g->select_radius_m( $lat0, $lon0, $this->d * 1000, |
| 79 | + $this->attr['region'], $this->attr['type'] ); |
77 | 80 | $all = array(); |
78 | 81 | $all_pos = array(); /* temporary store reqd due to sort */ |
79 | 82 | |
Index: trunk/extensions/gis/database.php |
— | — | @@ -156,8 +156,9 @@ |
157 | 157 | /** |
158 | 158 | * Select entities with a certain radius expressed in meters |
159 | 159 | * FIXME: Does not work properly around the poles... |
| 160 | + * Also select by region and type if specified |
160 | 161 | */ |
161 | | - function select_radius_m( $lat, $lon, $r ) |
| 162 | + function select_radius_m( $lat, $lon, $r, $region, $type ) |
162 | 163 | { |
163 | 164 | $delta_lat = $r / (60 * 1852); |
164 | 165 | $c = cos($lat * (M_PI / 180)); |
— | — | @@ -172,19 +173,27 @@ |
173 | 174 | $lonmin = $lon - $delta_lon; |
174 | 175 | $lonmax = $lon + $delta_lon; |
175 | 176 | return $this->select_area( $latmin, $lonmin, |
176 | | - $latmax, $lonmax ); |
| 177 | + $latmax, $lonmax, $region, $type ); |
177 | 178 | } |
178 | 179 | |
179 | 180 | /** |
180 | 181 | * Select entities belonging to or overlapping an area |
| 182 | + * Also select by region and type if specified |
181 | 183 | */ |
182 | | - function select_area( $latmin, $lonmin, $latmax, $lonmax ) |
| 184 | + function select_area( $latmin, $lonmin, $latmax, $lonmax, $region, $type ) |
183 | 185 | { |
184 | | - $condition = 'gis_latitude_max >= ' . $latmin . |
185 | | - ' AND gis_latitude_min <= ' . $latmax . |
186 | | - ' AND gis_longitude_max >= ' . $lonmin . |
187 | | - ' AND gis_longitude_min <= ' . $lonmax; |
| 186 | + $condition = "gis_latitude_max >= " . $latmin . |
| 187 | + " AND gis_latitude_min <= " . $latmax . |
| 188 | + " AND gis_longitude_max >= " . $lonmin . |
| 189 | + " AND gis_longitude_min <= " . $lonmax; |
188 | 190 | |
| 191 | + if ($region) { |
| 192 | + $condition .= " AND gis_region = '" . $region . "'"; |
| 193 | + } |
| 194 | + if ($type) { |
| 195 | + $condition .= " AND gis_type = '" . $type . "'"; |
| 196 | + } |
| 197 | + |
189 | 198 | return $this->select_position( $condition ); |
190 | 199 | } |
191 | 200 | |
— | — | @@ -202,8 +211,8 @@ |
203 | 212 | 'gis_latitude_max', |
204 | 213 | 'gis_longitude_min', |
205 | 214 | 'gis_longitude_max', |
206 | | - 'gis_type', |
207 | | - 'gis_region' ), |
| 215 | + 'gis_region', |
| 216 | + 'gis_type' ), |
208 | 217 | $condition, |
209 | 218 | $fname ); |
210 | 219 | |
Index: trunk/extensions/gis/maparea.php |
— | — | @@ -33,10 +33,12 @@ |
34 | 34 | */ |
35 | 35 | class maparea { |
36 | 36 | var $p; |
| 37 | + var $attr; |
37 | 38 | |
38 | 39 | function maparea( $coor ) |
39 | 40 | { |
40 | 41 | $this->p = new geo_param( $coor ); |
| 42 | + $this->attr = $this->p->get_attr(); |
41 | 43 | } |
42 | 44 | |
43 | 45 | function show() |
— | — | @@ -63,7 +65,8 @@ |
64 | 66 | { |
65 | 67 | $g = new gis_database(); |
66 | 68 | $g->select_area( $this->p->latdeg_min, $this->p->londeg_min, |
67 | | - $this->p->latdeg_max, $this->p->londeg_max); |
| 69 | + $this->p->latdeg_max, $this->p->londeg_max, |
| 70 | + $this->attr['region'], $this->attr['type'] ); |
68 | 71 | |
69 | 72 | $out = ";type:abstract\r\n" |
70 | 73 | . ";comment:" |