[英]Geoserver dynamically set bounding box / referencedEnvelope of datastore/layer when creating
I am using geoserver
. 我正在使用
geoserver
。 I extended ContentDataStore
plugin to add csv data types as layers. 我扩展了
ContentDataStore
插件以将csv数据类型添加为图层。 I am using geoserver rest api
, HTTPUtils.put
method actually. 我实际上正在使用
geoserver rest api
, HTTPUtils.put
方法。 When I do this the datastore gets created without boundingbox defined, unlike when it is created manually on geoserver web application
. 执行此操作时,将在未定义边界
geoserver web application
情况下创建数据存储,这与在geoserver web application
上手动创建数据存储不同。 Therefore I get an exception when I try to use wms-getCapabilities
method, because there is no boundingbox defined. 因此,当我尝试使用
wms-getCapabilities
方法时,由于未定义边界wms-getCapabilities
,因此会出现异常。
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. 有没有一种方法可以为
xxxDataStore or xxxDataStoreFactory
类中的数据存储/图层定义边界xxxDataStore or xxxDataStoreFactory
。 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
. 第一个是
xxxFeatureSource
,它扩展了ContentFeatureSource
(在ContentDataStore插件中),第二个是DataStoreFileResource
。
In xxxFeatureSource
I overrided ReferencedEnvelope getBoundsInternal()
method and implemented code which calculates my boundingBox. 在
xxxFeatureSource
我重写了ReferencedEnvelope getBoundsInternal()
方法,并实现了计算我的boundingBox的代码。
In DataStoreFileResource
I added this line; 在
DataStoreFileResource
我添加了这一行;
ftInfo.setLatLonBoundingBox( bounds );
into the void handlePut()
method, right after ftInfo.setNativeBoundingBox( bounds )
. ftInfo.setNativeBoundingBox( bounds )
在ftInfo.setNativeBoundingBox( bounds )
之后的void handlePut()
方法中。
Now I can use getCapabilities method after adding my DataStore via GeoServer rest api. 现在,通过GeoServer rest api添加数据存储后,我可以使用getCapabilities方法。
Hope it helps others too. 希望它也能帮助其他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.