0

I am trying to get some features from GeoServer if they are inside a certain area, after making a request to the local GeoServer I get the following error:

org.opengis.referencing.NoSuchAuthorityCodeException: No authority was defined for code "-5398011,-3010158,-5446939,-3010158". Did you forget "AUTHORITY:NUMBER"?

I got those coordinates in the dragbox end function of OpenLayers:

dragBox.on("boxend", function () {
  var rotation = map.getView().getRotation();
  var oblique = rotation % (Math.PI / 2) !== 0;
  var candidateFeatures = oblique ? [] : selectedFeatures;
  var alimentadores = [];
  var equipamentos = [];
  var bbox = dragBox.getGeometry().getCoordinates();
...url = ...+ "&BBOX=" +    extent.join(",") 

The request URL:

http://localhost:8080/geoserver/Workspace/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=Workspace:layer&outputFormat=application%2Fjson&srsname=EPSG:4326&BBOX=-5446939,-3049279,-5398011,-3049279,-5398011,-3010158,-5446939,-3010158

0

2 Answers 2

2

The bbox should be the extent of the dragbox geometry, not its coordinates. You should also specify its projection code, which will be your view projection

var extent = dragBox.getGeometry().getExtent();

url = ... + "&BBOX=" + extent.join(",") + ',' + map.getView().getProjection().getCode();
1

A bbox is defined by 4 numbers, the lower left x and y and the upper right x and y coordinates.

Also your coordinates are not in epsg:4326 so you probably want to add an srs code in the form epsg:xxxxx to the end of the bbox

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .