0

I am using GeoServer with a plugin for a NoSQL backend. I am sending the equivalent of a CQL query to select a portion of a dataset and plot in on the map... like thousands of points. My plotting and querying is correct, but from what I understand GeoServer will not provide the bounding box/extent(I don't know which term is correct) for the result set.

What I've done as a work around is select the max(lat), max(lon), min(lat) and min(lon) from the result set. This should give me an area of results.

Using OpenLayers, I want to pan/zoom the map to that bounding box or extent (whichever word is correct). I see there is a Map.getView().fit() command, but I'm not sure what needs to be done to massage the data. My 4 points are in EPSG:4326 so I need to project them to 3857 and then put them into a format that the fit() function will understand.

let original_extent = new ol_extent.boundingExtent(
          [this.extent_obj['min_surface_longitude'],
            this.extent_obj['min_surface_latitude'],
            this.extent_obj['max_surface_longitude'],
            this.extent_obj['max_surface_latitude'],
            ])

let new_extent = ol_proj.transformExtent(original_extent , "EPSG:4326", "EPSG:3857")
this.map.getView().fit(new_extent)

I have tried the above to no avail.

1 Answer 1

0

If you looks at the docs of .boundingExtent method, you can read:

Build an extent that includes all given coordinates.

where parameter coordinates is an array of coordinates, where coordinate is an array [lng, lat]. This means setting your original_extent should look like this:

let original_extent = new ol_extent.boundingExtent([
  [this.extent_obj['min_surface_longitude'], this.extent_obj['min_surface_latitude']],
  [this.extent_obj['max_surface_longitude'], this.extent_obj['max_surface_latitude']]
]);

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.