以下是我使用的代码,它不起作用
curl -v -u admin:geoserver -XPUT -H 'Content-type: text/xml' -d
'<featureType>
<name>h12v10_locations_20ztesting</name>
<nativeName>h12v10_locations_20ztesting</nativeName>
<srs>EPSG:4326</srs>
<metadata><entry>
<virtualTable><name>h12v10_locations_20ztesting</name>
<sql>select gid, poly_label, data_score, data_time, year, the_geom
from h12v10_locations_2002
order by gid asc</sql>
<keyColumn>feature_id</keyColumn>
<geometry><name>the_geom</name><type>POINT</type><srid>4326</srid></geometry>
</virtualTable></entry></metadata></featureType>'
http://localhost:8080/geoserver/rest/layers/cite:h12v10_locations_20ztesting.xml
我想使用sql视图而不是创建图层是当我更新数据是PostGIS时,客户端检索的数据条目的顺序会发生变化。例如,当我更新id = 1时,检索到的第一个条目将从id = 1
变为id = 2答案 0 :(得分:8)
经过一些试验和错误后我找到了解决方案^ _ ^
curl -v -u admin:geoserver -XPOST -H 'Content-type: text/xml' -d '
<featureType>
<name>h12v10_locations_2004new</name>
<nativeName>h12v10_locations_2004new</nativeName>
<namespace>
<name>cite</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://arizona-umh.cs.umn.edu:8080/geoserver/rest/namespaces/cite.xml" type="application/xml"/>
</namespace>
<title>h12v10_locations_2004new</title>
<keywords>
<string>features</string>
<string>h12v10_locations_2004new</string>
</keywords>
<srs>EPSG:4326</srs>
<projectionPolicy>FORCE_DECLARED</projectionPolicy>
<enabled>true</enabled>
<metadata>
<entry key="cachingEnabled">false</entry>
<entry key="JDBC_VIRTUAL_TABLE">
<virtualTable>
<name>h12v10_locations_2004new</name>
<sql>select gid, poly_label, data_score, data_time, year, the_geom from h12v10_locations_2004 order by gid asc</sql>
<escapeSql>false</escapeSql>
<keyColumn>gid</keyColumn>
<geometry>
<name>the_geom</name>
<type>Point</type>
<srid>4326</srid>
</geometry>
</virtualTable>
</entry>
</metadata>
<store class="dataStore">
<name>AlwaysShen</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://arizona-umh.cs.umn.edu:8080/geoserver/rest/workspaces/cite/datastores/AlwaysShen.xml" type="application/xml"/>
</store>
<maxFeatures>0</maxFeatures>
<numDecimals>0</numDecimals>
</featureType>'
http://localhost:8080/geoserver/rest/workspaces/cite/datastores/AlwaysShen/featuretypes/
希望这可以帮助那些花费数小时和数天搜索谷歌并且没有发现真正解决这个特定问题的人:)