简体   繁体   English

Geoserver在创建时动态设置数据存储区/图层的边界框/ referencedEnvelope

[英]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 apiHTTPUtils.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM