[mapserver-users] Single image mapfile

Lime, Steve D (MNIT) Steve.Lime at state.mn.us
Mon Oct 10 11:58:06 PDT 2016


It is possible but it's a two-step process within MapServer. It looks like so (I think):



MAP

  EXTENT [bbox of whole dataset]



  LAYER

    NAME 'myraster'

    TYPE RASTER

    STATUS OFF

    ... stuff to draw the raster ...

  END



  LAYER

    NAME 'myfeature'

    TYPE QUERY

    STATUS OFF

    CONNTECTIONTYPE POSTGIS

    CONNECTION ...

    DATA 'shape FROM (SELECT * FROM myfeatures) as foo USING UNIQUE feature_id'

    VALIDATION

       'qstring' '^[0-9]{1,5}$'

    END

    TEMPLATE 'http://your_base_url_for_mapserver?mode=map&map=[map]&layer=myraster&mapext=[shpext expand="1000" escape="url"]'

  END

END



To make a map you'd issue a query against the myfeature layer.



  http://your_base_url_for_mapserver?map=yourmapfile.map&mode=itemquery&qlayer=myfeature&qitem=feature_id&qstring=123



The query does an item query against the myfeature where feature_id=123. The validation block allows you to limit values for the feature_id. The TEMPLATE then determines where MapServer should redirect the request based on the selected feature – this gets you the right map. The shpext tag will take the point geometry extent (minx=maxx and miny=maxy) and then expands it by 1000 map units before returning the string as a space delimited (and escaped) extent.



I've used this strategy before and it works well...



Steve



-----Original Message-----
From: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Dave Barter
Sent: Monday, October 10, 2016 10:58 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] Single image mapfile



Would this be feasible in a mapfile alone?



I pass in a url with a feature_id in it. Say:-



[URL TO MAP FILE]?feature_id=124



The map file uses a postgres query to retrieve the feature_id’s geometry as a point and then clips a raster layer to a kilometre bounding box around the point.



A single jpg/tif/png would be returned with the point marked in the correct position on the raster





This url could then be used on a webpage to show a small map snippet for the feature’s location.





Dave Barter

dave at phased.co.uk<mailto:dave at phased.co.uk>

@citizenfishy

www.phased.co.uk<http://www.phased.co.uk>



_______________________________________________

mapserver-users mailing list

mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>

http://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20161010/15769d74/attachment.htm>


More information about the MapServer-users mailing list