We have a requirement to email out a map showing a particular feature in our database. When the query is made to generate the map all it has is a feature id. All the queries I've seen to MapServer/WMS include a BBOX. Is it possible to calculate the BBOX based on the feature id?

The feature id will be stored in a PostGIS/PostgreSQL database.

  • can your client access the database directly?
    – Ian Turton
    Commented Aug 10, 2019 at 15:06
  • Its possible but I was trying to do it with just one query. Commented Aug 10, 2019 at 19:06
  • You can use a WFS call to GetFeatureById
    – nmtoken
    Commented Aug 11, 2019 at 17:38
  • All WMS GetMap requests require a BBOX, with extents specified in the coordinate reference system of the request data. That's not specific to a MapServer WMS. Any BBOX can be specified, it doesn't have to match the extent of the feature (but if if it doesn't coincide, you'll get no map image)
    – nmtoken
    Commented Aug 12, 2019 at 9:20

1 Answer 1


Neither the WMS protocol nor any of the other MapServer APIs have a mechanism to automatically set the map position and zoom level based on a geometry object.

You have to retrieve the bounding box with a separate query (through WFS, or directly to the database).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.