Как написать WFS-транзакции вставки с геосервером / postgrsql - PullRequest
0 голосов
/ 17 апреля 2019

У меня есть база данных и сервер tomcat / geoserver, и я пытаюсь обмениваться данными с openlayers. Поэтому я пытаюсь написать транзакцию WFS без успеха. Я не знаю, что не так, геометрия? Я попытался скопировать приведенный в демонстрации пример без дальнейшего успеха:

<ows:ExceptionReport version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://ip_address:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"><ows:Exception exceptionCode="InvalidParameterValue"><ows:ExceptionText>Error performing insert: Error inserting features</ows:ExceptionText></ows:Exception></ows:ExceptionReport>

моя попытка:

<wfs:Transaction service="WFS" version="1.1.0"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:cite="http://www.opengeospatial.net/cite"
  xmlns:gml="http://www.opengis.net/gml"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd http://www.opengeospatial.net/cite http://ip_address:8080/geoserver/wfs/DescribeFeatureType?typename=cite:administration">
  <wfs:Insert>
    <cite:administration>
      <cite:geom>
        <gml:MultiPolygon xmlns="http://www.opengis.net/gml" srsName="EPSG:2154"><gml:polygonMember><gml:Polygon srsName="EPSG:3857"><gml:exterior><gml:LinearRing srsName="EPSG:2154"><gml:posList srsDimension="2">1033195.5041126036 6284576.928642391 1033176.0281535687 6284534.392003635 1033215.4422350351 6284544.237956143 1033195.5041126036 6284576.928642391</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:polygonMember></gml:MultiPolygon>
      </cite:geom>
    </cite:administration>
  </wfs:Insert>
</wfs:Transaction>

описание FeatuyreType

<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cite="http://www.opengeospatial.net/cite" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:wfs="http://www.opengis.net/wfs/2.0" elementFormDefault="qualified" targetNamespace="http://www.opengeospatial.net/cite">
  <xsd:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="ip_address:8080/geoserver/schemas/gml/3.2.1/gml.xsd"/>
  <xsd:complexType name="administrationType">
    <xsd:complexContent>
      <xsd:extension base="gml:AbstractFeatureType">
        <xsd:sequence>
          <xsd:element maxOccurs="1" minOccurs="0" name="surface" nillable="true" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="annee_prescription" nillable="true" type="xsd:int"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="ro" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="numope" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="typope" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="geom" nillable="true" type="gml:MultiSurfacePropertyType"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="typemp" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="nomope" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="numoa" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="numprescr" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="tranche" nillable="true" type="xsd:int"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="code_tranche" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="surfaceC_ha" nillable="true" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="ratioC_ha" nillable="true" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="amenageur" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="opérateur" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="prescripteur" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="statut_contractuel" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="statut_operationnel" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
  <xsd:element name="administration" substitutionGroup="gml:AbstractFeature" type="cite:administrationType"/>
</xsd:schema>

Srs является EPSG: 2154

транзакция openlayers, которая также не работает:

var wfst = new ol.format.WFS({
    featureNS: "http://www.opengeospatial.net/cite",
    featureType: "cite:administration"
});
var options = {
    srsName: "EPSG:2154",
    featureNS: "http://www.opengeospatial.net/cite",
    featurePrefix:'cite',
    featureType: "cite:administration",
    gmlOptions:{featureNS: "http://www.opengeospatial.net/cite",featureType: "cite:administration",srsName: "EPSG:2154"}
};
    var node = wfst.writeTransaction(features2154,null,null,options);
    console.log('node',node);
    var s = new XMLSerializer();
    var str = s.serializeToString(node);

Результат str =

<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Insert><cite:administration xmlns:cite="http://www.opengeospatial.net/cite"><cite:geometry><MultiPolygon xmlns="http://www.opengis.net/gml" srsName="EPSG:2154"><polygonMember><Polygon srsName="EPSG:2154"><exterior><LinearRing srsName="EPSG:2154"><posList srsDimension="2">1033187.44577774 6284581.696198352 1033171.7481650712 6284533.302464095 1033221.5049866531 6284544.554293833 1033187.44577774 6284581.696198352</posList></LinearRing></exterior></Polygon></polygonMember></MultiPolygon></cite:geometry><cite:collectedProperties>[object Object]</cite:collectedProperties></cite:administration></Insert></Transaction>

1 Ответ

0 голосов
/ 21 апреля 2019

мой ответ: в ней отсутствовали необходимые атрибуты для транзакции (не нулевые значения в исключении POSTGIS)

<wfs:Transaction service="WFS" version="1.1.0"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:cite="http://www.opengeospatial.net/cite"
  xmlns:gml="http://www.opengis.net/gml"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd http://www.opengeospatial.net/cite http://IP:8080/geoserver/wfs/DescribeFeatureType?typename=cite:prescription">
  <wfs:Insert>
    <cite:prescription>
      <cite:geom>
        <gml:MultiPolygon xmlns="http://www.opengis.net/gml" srsName="EPSG:2154"><gml:polygonMember><gml:Polygon srsName="EPSG:2154"><gml:exterior><gml:LinearRing srsName="EPSG:2154"><gml:posList srsDimension="2">1033195.5041126036 6284576.928642391 1033176.0281535687 6284534.392003635 1033215.4422350351 6284544.237956143 1033195.5041126036 6284576.928642391</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:polygonMember></gml:MultiPolygon>
      </cite:geom>
      <cite:numope>D000000</cite:numope>
      <cite:numoa>11111111</cite:numoa>
      <cite:annee_prescription>2020</cite:annee_prescription> 
      <cite:ro>albert</cite:ro> 
      <cite:typope>diagnostic</cite:typope>
<cite:typemp>prescrite</cite:typemp>
    </cite:prescription>
  </wfs:Insert>
</wfs:Transaction>
...