[mapserver-users] problems with KML output in context of WFS GetFeature

Peter Freimuth peter.freimuth at blackbridge.com
Wed Sep 24 07:40:11 PDT 2014


Hi Mapserver Users,

We have a problem with creating KML output from a PostGIS db in context of a GetFeature request version=1.1.0 outputformat=kml.

The problem is that not all attributes are exported and that the values are shifted, means the mapping between value ad attribute name is wrong.

This is the request:

http://localhost/cgi-bin/catalog_view.fcgi?typename=coveragepols&searchid=6ca8dd30-43b8-11e4-9804-00163e437838&SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&SRS=EPSG:4326&outputformat=kml

This is the mapserv config:
<!-- MapServer version 6.4.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->

This is the outputformat declaration from the mapfile:
    OUTPUTFORMAT
        NAME "kml"
        DRIVER "OGR/KML"
        MIMETYPE "application/vnd.google-earth.kml.xml"
        FORMATOPTION "STORAGE=memory"
        FORMATOPTION "FORM=SIMPLE"
        FORMATOPTION "FILENAME=catalog_search_result.kml"
    END

This is the layer from the mapfile:
    #----------------------------------------------------------------------------------------------------------------------------#
    # This layer serves a WMS representation of the coverage polygons and a WFS for the related metadata
    #----------------------------------------------------------------------------------------------------------------------------#    LAYER
        NAME "coveragepols"
        TYPE POLYGON
        STATUS ON
        DEBUG 5
        UNITS meters #dd
        SIZEUNITS PIXELS
        TOLERANCE 3
        TOLERANCEUNITS PIXELS
        MINSCALE 1000
        MAXSCALE 10000000
        LABELITEM "label"
        LABELMAXSCALEDENOM 1400000
        PROCESSING "CLOSE_CONNECTION=DEFER"
        CONNECTIONTYPE POSTGIS
        CONNECTION"user=nnnn password=nnnn dbname=nnnn host='localhost' port=5432"
        DATA "coverage_poly FROM (SELECT product_identifier, product_identifier||'_'||cast(acquisition_date as date)::text as label,
                                         imagetake_cat_id as it_cat_id, tile_id, spacecraft_id, cloud_cover, black_fill, acquisition_date,
                                         image_path, id as image_id, search_request_id as search_id,
                                         tileid_stack_order, roll_angle as view_angle, metadata_url,
                                         st_asewkt(st_transform(footprint,3785)::geometry) as footprint,
                                         st_transform(coveragepoly,3785) as coverage_poly
                             FROM catalog_search_view.view_service
                             WHERE search_request_id='%searchid%' AND is_visible=TRUE
                             ORDER BY product_identifier, tile_id, tileid_stack_order ASC, acquisition_date ASC, cloud_cover ASC, black_fill ASC
                             ) foo USING UNIQUE image_id USING SRID=3785"
        PROJECTION
            "init=epsg:3785" #Google Projection ( new code )
            #"init=epsg:4326"
        END
        VALIDATION
            'searchid' '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
            'default_searchid' '5b7257a0-d9df-11e3-b7e2-b4b52fd4696c'
        END
        METADATA
            "ows_title" "Coverage Polygons"
            "ows_extent" "-20037508.34 -20037508.34 20037508.34 20037508.34"
            #"ows_extent" "-180 -89 180 89"
            "wms_srs" "EPSG:3857 EPSG:3785 EPSG:900913 EPSG:4326" #output
            "wfs_getfeature_formatlist"  "geojson,shapezip,csv"
            "wfs_featureid" "image_id"
            "wfs_getfeature_formatlist"  "geojson,shapezip,csv,kml "
            "wfs_geomtype"  "Polygon"
            "gml_include_items" "all"
            "gml_exclude_items" ""
            "gml_types" "auto"
        END
        CLASS
            NAME "Coverage Polygons"
            #STYLE
            #   COLOR 231 182 21
            #END
            STYLE
                OUTLINECOLOR 10 255 0
                WIDTH 2
            END
            LABEL
...
            END
        END
    END


This is the resulting KML:

<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Folder><name>coveragepols</name>
  <Placemark>
                <name>8971800</name>
                <description>8971800_2012-04-01</description>
                <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
                <ExtendedData><SchemaData schemaUrl="#coveragepols">
                                <SimpleData name="product_identifier">8971799</SimpleData>
                                <SimpleData name="label">2131328</SimpleData>
                                <SimpleData name="it_cat_id">0</SimpleData>
                                <SimpleData name="tile_id">2</SimpleData>
                                <SimpleData name="spacecraft_id">70</SimpleData>
                                <SimpleData name="cloud_cover">2012</SimpleData>
                                <SimpleData name="black_fill">0</SimpleData>
                                <SimpleData name="image_path">6ca8dd30-43b8-11e4-9804-00163e437838</SimpleData>
                                <SimpleData name="search_id"></SimpleData>
                                <SimpleData name="view_angle">0</SimpleData>
                </SchemaData></ExtendedData>
      <Polygon><outerBoundaryIs><LinearRing><coordinates>-53.842662603651206,-16.845382012603906 -53.8416445,-16.911957400000013 -54.050696106229296,-16.914945332724113 -54.029782739899993,-16.81954737480001 -53.842662603651206,-16.845382012603906</coordinates></LinearRing></outerBoundaryIs></Polygon>
  </Placemark>
....

Everything works fine with GML2,3, geojson, csv, shapezip.
This is an example of the  gml2 output:
<gml:featureMember>
<re:coveragepols fid="coveragepols.7870">
<gml:boundedBy><gml:Box srsName="EPSG:4326"><gml:coordinates>-16.914945,-54.050696 -16.819547,-53.841645</gml:coordinates></gml:Box></gml:boundedBy>
<re:msGeometry><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-16.845382,-53.842663 -16.911957,-53.841645 -16.914945,-54.050696 -16.819547,-54.029783 -16.845382,-53.842663 </gml:coordinates>
</gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></re:msGeometry>
<re:product_identifier>8971800</re:product_identifier>
<re:label>8971800_2012-04-01</re:label>
<re:it_cat_id>8971799</re:it_cat_id>
<re:tile_id>2131328</re:tile_id>
<re:spacecraft_id>RapidEye-2</re:spacecraft_id>
<re:cloud_cover>2</re:cloud_cover>
<re:black_fill>70</re:black_fill>
<re:acquisition_date>2012-04-01 14:54:13+00</re:acquisition_date>
<re:image_path>/data/browse_images/re/itt_it/2012/4/1/8971799/2131328_2012-04-01_8971799_8971800_browse.tif</re:image_path>
<re:image_id>7870</re:image_id>
<re:search_id>6ca8dd30-43b8-11e4-9804-00163e437838</re:search_id>
<re:tileid_stack_order/>
<re:view_angle/>
<re:metadata_url/>
<re:footprint>SRID=3785;MULTIPOLYGON(((-6020089.94663019 -1884323.72494587,-5993595.17046117 -1884323.72494587,-5993595.17046117 -1910982.75368706,-6020089.94663019 -1910982.75368706,-6020089.94663019 -1884323.72494587)))</re:footprint>
</re:coveragepols>
</gml:featureMember>


Any idea what I need to change to get this working properly?? Any hint or a solution is welcome.

Peter
BlackBridge AG | Sitz Berlin | Amtsgericht Charlottenburg - Registergericht | HRB 152785 | Aufsichtsratsvorsitzender: David Westwood | Vorstand: Ryan Johnson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140924/4cabbe16/attachment.htm>


More information about the MapServer-users mailing list