【问题标题】:how to create SQL View in Geoserver with command line如何使用命令行在 Geoserver 中创建 SQL 视图
【发布时间】:2015-08-12 23:12:01
【问题描述】:

以下是我使用的代码,不起作用

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

【问题讨论】:

    标签: sql view postgis geoserver


    【解决方案1】:

    经过反复试验,我找到了解决方案^_^

    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/
    

    希望这可以帮助那些花费数小时和数天在谷歌上搜索却一无所获的人真正解决了这个特定问题:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多