Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Commit

Permalink
Fixed automatic zoom when data coordinates do not match map coordinat…
Browse files Browse the repository at this point in the history
…es. refs: geomoose/geomoose#90

This is a multipart fix:
1. Coordinates were being projected back to the native dataset coordinate system which is not necessarily the mapping coordinates.
   They are now returned in WGS84/LatLon
2. GeoMOOSE was not allowing the user to specify a reprojection of extents in zoomToExtent (fixed in geomoose-js)
  • Loading branch information
Dan Little committed Jul 10, 2015
1 parent 6d62844 commit dacfa7e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
5 changes: 3 additions & 2 deletions php/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ public function toSQL() {
# or zoom to the first result if requested.
if(($totalResults == 1 and $firstResult != false) or ($totalResults >= 1 and $zoomToFirst == true)) {
$bounds = $resultFeatures[0]->bounds;
$bounds->project($LATLONG_PROJ, $projection);
printf('GeoMOOSE.zoomToExtent(%f,%f,%f,%f);', $bounds->minx, $bounds->miny, $bounds->maxx, $bounds->maxy);
#$outputProjection = ms_newprojectionobj('epsg:4326');
#$bounds->project($LATLONG_PROJ, $outputProjection);
printf('GeoMOOSE.zoomToExtent(%f,%f,%f,%f, "EPSG:4326");', $bounds->minx, $bounds->miny, $bounds->maxx, $bounds->maxy);
}
print "]]></script>";
print "<html><![CDATA[";
Expand Down
49 changes: 49 additions & 0 deletions tests/query_php_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from select_php_test import ParcelTest

import re

class QueryTest(ParcelTest):
def setUp(self):
super(QueryTest,self).setUp()
Expand Down Expand Up @@ -202,6 +204,53 @@ def test_null_case(self):
regex = 'mapObj..queryByRect'
r = self.check_parcels(like_any_test, [], regex)

def test_bad_zoom_coordinates(self):
"""
Check that zoom coordinates are valid from searches. (Ticket #90)
"""

# this test does not check for parcel validity,
# it needs to parse zoom coordinates, so it does not use
# "check_parcels", hence a manually setup test.
query_php = "http://" + self.host + self.geomoose_base + "/php/query.php"

params = {
'highlight' : 'true',
'mode' : 'search',
'layer0' : 'parcels/parcels',
'template0' : 'itemquery',
'fieldname0' : 'PIN',
'comparitor0' : 'like-icase',
'value0' : '130220003076',
'fieldname1' : 'FIN_SQ_FT',
'operator1' : 'or',
'comparitor1' : 'gt',
'value1' : ''
}


req = self.post(query_php, params=params)

#GeoMOOSE.zoomToExtent(483512.041622,4935870.833973,483612.169900,4936007.072803)
self.assertEqual(req.status_code, 200, "Zoom test returned invalid status code")
pattern = r".*GeoMOOSE\.zoomToExtent\((?P<minx>[\-0-9\.]+),(?P<miny>[\-0-9\.]+),(?P<maxx>[\-0-9\.]+),(?P<maxy>[\-0-9\.]+), .EPSG.(?P<proj>[0-9]+).\).*"

zoom_match = re.match(pattern, req.text.replace('\n', ' '))

self.assertIsNotNone(zoom_match, "Could not find zoomToExtent string in search results.")

coordinates = zoom_match.groupdict()
correct = {
'minx': u'-93.207671', 'miny': u'44.575991',
'maxx': u'-93.206415', 'maxy': u'44.577215',
'proj': u'4326'
}

# verify the results actually pass.
for coord in correct:
self.assertEqual(coordinates[coord], correct[coord],
"Error in coordinates! %s does not match! (%s != %s)" % (coord, coordinates[coord], correct[coord]))




0 comments on commit dacfa7e

Please sign in to comment.