[Geomoose-users] Search based on lat/lon layer
Brent Fraser
bfraser at geoanalytic.com
Mon Apr 27 12:42:46 EDT 2009
Jim,
Regarding [shpmidx], etc (http://trac.osgeo.org/mapserver/ticket/2961); I did read it, but it doesn't apply here since an extent is needed (I want the entire polygon on the view), not just the centroid. I think your patch on [shpext] (http://trac.osgeo.org/mapserver/ticket/2894) is the fix for this problem.
Brent
Jim Klassen wrote:
> Did you see/read/try Steve's comment in the trac entry?
>
>>>> Brent Fraser <bfraser at geoanalytic.com> 04/27/09 10:10 AM >>>
> Jim,
>
> Looks like your patch will do the trick for the future. I'm trying to use a "stock" mapserver for this implementation (v5.2.1 from MS4W), and stay off the GeoMoose v2.0 Beta (with OpenLayers) bleeding edge, so I'll likely enhance the GeoMoose javascript...
>
> Thanks!
> Brent
>
> Jim Klassen wrote:
>> Two thoughts.
>>
>> 1) There have been recent changes to shpext and some of the other related tags in mapserver templates that support supplying an output projection. (or at least transforming them to the mapfiles output projection).... that reminds me I need to make a ticket for one of those changes.
>>
>> http://trac.osgeo.org/mapserver/ticket/2961
>>
>> Anyway... I already did that.
>> --- maptemplate.c (revision 8844)
>> +++ maptemplate.c (working copy)
>> @@ -3282,14 +3282,23 @@
>> }
>> }
>> }
>> -
>> - sprintf(repstr, "%f %f", (mapserv->resultshape.bounds.maxx + mapserv->resultshape.bounds.minx)/2, (mapserv->resultshape.bounds.maxy + mapserv->resultshape.bounds.miny)/2);
>> - outstr = msReplaceSubstring(outstr, "[shpmid]", repstr);
>> - sprintf(repstr, "%f", (mapserv->resultshape.bounds.maxx + mapserv->resultshape.bounds.minx)/2);
>> - outstr = msReplaceSubstring(outstr, "[shpmidx]", repstr);
>> - sprintf(repstr, "%f", (mapserv->resultshape.bounds.maxy + mapserv->resultshape.bounds.miny)/2);
>> - outstr = msReplaceSubstring(outstr, "[shpmidy]", repstr);
>> -
>> +
>> + {
>> + rectObj tempExtent;
>> + tempExtent.minx = mapserv->resultshape.bounds.minx;
>> + tempExtent.maxx = mapserv->resultshape.bounds.maxx;
>> + tempExtent.miny = mapserv->resultshape.bounds.miny;
>> + tempExtent.maxy = mapserv->resultshape.bounds.maxy;
>> + if(msProjectionsDiffer(&(mapserv->resultlayer->projection), &(mapserv->map->projection)))
>> + msProjectRect(&(mapserv->resultlayer->projection), &mapserv->map->projection, &tempExtent);
>> + sprintf(repstr, "%f %f", (mapserv->resultshape.bounds.maxx + mapserv->resultshape.bounds.minx)/2, (mapserv->resultshape.bounds.maxy + mapserv->resultshape.bounds.miny)/2);
>> + outstr = msReplaceSubstring(outstr, "[shpmid]", repstr);
>> + sprintf(repstr, "%f", (tempExtent.maxx + tempExtent.minx)/2);
>> + outstr = msReplaceSubstring(outstr, "[shpmidx]", repstr);
>> + sprintf(repstr, "%f", (tempExtent.maxy + tempExtent.miny)/2);
>> + outstr = msReplaceSubstring(outstr, "[shpmidy]", repstr);
>> + }
>> +
>> if(processExtentTag(mapserv, &outstr, "shpext", &(mapserv->resultshape.bounds), &(mapserv->resultlayer->projection)) != MS_SUCCESS)
>> return(NULL);
>> if(processExtentTag(mapserv, &outstr, "shpext_esc", &(mapserv->resultshape.bounds), &(mapserv->resultlayer->projection)) != MS_SUCCESS) /* depricated */
>>
>>
>> 2) You can reproject using the OpenLayers code: Something along the lines of: coord = {'x': x_coord, 'y': y_coord}; OpenLayers.Projection.transform({'x': lon, 'y': lat}, <insert your projection here>, LatLongProjection); ll = {'lon': coord.x, 'lat': coord.y} ; Map.panTo(ll);
>> (From memory, check the projection call from geomoose/main.js)
>>
>>>>> Brent Fraser <bfraser at geoanalytic.com> 04/24/09 4:32 PM >>>
>> I've got a layer in geographic coordinates I'd like to do a GeoMoose Search on. Unfortunately, Mapserver's shpminx/shpmaxx/shpminx/shpmaxx template values return the shape extents in the layer's coordinate system, not the map coordinate system, so the GeoMoose Map.zoomToViewString call in the itemquery template does not work.
>>
>> Has anyone got a Map.zoomToLatLonViewString function laying around?
>>
>> My other options are:
>> Convert the layer to the map projection (a maintenance nightmare)
>> Enhance Mapserver's [shpmin} handling to match it's [shpext proj=] abilities (too much work right now)
>>
>> Thanks!
>> Brent Fraser
>>
More information about the Geomoose-users
mailing list