wavded / ogre

ogr2ogr geojson-focused web client
http://ogre.adc4gis.com
MIT License
266 stars 79 forks source link

using fetch in typescript returns {"error":true,"message":"Unexpected field"} #113

Closed pcace closed 1 year ago

pcace commented 1 year ago

Hi there, maybe you can help me with this problem: i am trying to use ogre from a typescript react component, but always get this return: {"error":true,"message":"Unexpected field"} this is the component i am trying to get to work:

useEffect(() => {
    const url = 'http://ogre.adc4gis.com/convert'

    const sourceSrs = 'EPSG:25833'
    const targetSrs = 'EPSG:4326'

    const sourceData = `
    <wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:fis="http://www.berlin.de/broker" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberMatched="403860" numberReturned="1" timeStamp="2023-04-11T11:16:20.275" xsi:schemaLocation="http://www.berlin.de/broker https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_alkis?REQUEST=DescribeFeatureType&SERVICE=WFS&VERSION=2.0.0&TYPENAMES=fis:s_wfs_alkis http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd">
      <wfs:boundedBy>
      <gml:Envelope>
      <gml:lowerCorner>375161.4919999996 5824742.937999999</gml:lowerCorner>
      <gml:upperCorner>375193.1490000002 5824777.863</gml:upperCorner>
      </gml:Envelope>
      </wfs:boundedBy>
        <wfs:member>
          <fis:s_wfs_alkis gml:id="s_wfs_alkis.1">
          <fis:bezeich>AX_Flurstueck</fis:bezeich>
          <fis:afl>603.0</fis:afl>
          <fis:fsko>11001000400752____</fis:fsko>
          <fis:zae>752</fis:zae>
          <fis:nen/>
          <fis:gmk>0010</fis:gmk>
          <fis:namgmk>Spandau</fis:namgmk>
          <fis:fln>4</fis:fln>
          <fis:gdz>11000005</fis:gdz>
          <fis:namgem>Spandau</fis:namgem>
          <fis:zde/>
          <fis:dst>1119</fis:dst>
          <fis:beg>2018-04-03T09:13:44</fis:beg>
          <fis:statusdat>2022-01-03T19:46:31</fis:statusdat>
          <fis:uuid>DEBE00YYCW00003I</fis:uuid>
            <fis:geom>
              <gml:MultiSurface gml:id="P1">
                <gml:surfaceMember>
                  <gml:Polygon gml:id="P2">
                    <gml:exterior>
                      <gml:LinearRing>
                      <gml:posList count="7">375179.9210000001 5824742.937999999 375161.4919999996 5824744.664999999 375164.86400000006 5824752.975 375174.38100000005 5824773.363 375176.4879999999 5824777.863 375193.1490000002 5824770.038000001 375179.9210000001 5824742.937999999</gml:posList>
                      </gml:LinearRing>
                    </gml:exterior>
                  </gml:Polygon>
                </gml:surfaceMember>
              </gml:MultiSurface>
            </fis:geom>
          </fis:s_wfs_alkis>
        </wfs:member>
    </wfs:FeatureCollection>
    `

    async function convertString() {
      const file = new Blob([sourceData], { type: 'application/xml' })
      const data = new FormData()
      data.append('data', file, 'testfile.gml')

      const params = new URLSearchParams({
        sourceSrs: sourceSrs,
        targetSrs: targetSrs,
        upload: 'testfile.gml',
      })
        upload: 'testfile.gml',
      })
      const request = `${url}?${params}`
      console.log('DEBUG REQUEST', request)
      const response: Response = await fetch(request, {
        method: 'POST',
        body: data,
      })

      const queryResult = await (await response.blob()).text()
      setResult(queryResult)
    }

    if (!result) {
      convertString()
    }
  }, [bbox])

and this is how it looks looking at the result from chrome:

image image

if you have any idea where the problem lies, it would be awesome to hear from you! Thanks a lot!

pcace commented 1 year ago

sorry... this needs to be "upload":

  data.append('data', file, 'testfile.gml')

-->

  data.append('upload', file, 'testfile.gml')