I am using geoserver
. I extended ContentDataStore
plugin to add csv data types as layers. I am using geoserver rest api
, HTTPUtils.put
method actually. When I do this the datastore gets created without boundingbox defined, unlike when it is created manually on geoserver web application
. Therefore I get an exception when I try to use wms-getCapabilities
method, because there is no boundingbox defined.
The getCapabilities query is below:
localhost:8090/geoserver/wms?Service=WMS&Version=1.1.1&Request=GetCapabilities
The inner exception is below:
Caused by: java.lang.NullPointerException
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLatLonBBox(GetCapabilitiesTransformer.java:1349)
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLayer(GetCapabilitiesTransformer.java:901)
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLayerTree(GetCapabilitiesTransformer.java:826)
... 90 more
Is there a way to define boundingbox for a datastore/layer in xxxDataStore or xxxDataStoreFactory
classes. So far I couldn't find any way to define while creating the datastore.
Thanks in advance
I found the answer to it. I changed 2 classes. The first one is xxxFeatureSource
which extends ContentFeatureSource
(it's in ContentDataStore plugin) and the second one is DataStoreFileResource
.
In xxxFeatureSource
I overrided ReferencedEnvelope getBoundsInternal()
method and implemented code which calculates my boundingBox.
In DataStoreFileResource
I added this line;
ftInfo.setLatLonBoundingBox( bounds );
into the void handlePut()
method, right after ftInfo.setNativeBoundingBox( bounds )
.
Now I can use getCapabilities method after adding my DataStore via GeoServer rest api.
Hope it helps others too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.