[mapserver-users] Re: WFS GetFeature on Mapserver doesn't work

sunny74 sb.ray at hotmail.com
Thu Apr 15 10:10:21 EDT 2010


Hi Rahkonen,

I finally got two map files to work.
The first one I created using your technique i.e copy paste sample code from
wfs_server.html and then made necessary changes.

The first which uses shape file as data source is as follows:

NAME "Rail_WFS"
STATUS ON
SIZE 600 600
SYMBOLSET "symbols.sym"
EXTENT 67.440106 17.379867 78.390250 25.122977
UNITS METERS
SHAPEPATH "C:/ms4w/apache/htdocs/Shape"
IMAGECOLOR 255 255 255
FONTSET "fonts.txt"
CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"


WEB
  IMAGEPATH "/ms4w/tmp/ms_tmp/"
  IMAGEURL "/ms_tmp/"
  METADATA
    "wfs_title"            "GMap WFS Demo Server"  ## REQUIRED
    "wfs_onlineresource"   "http://127.0.0.1/cgi-bin/mapserv.exe?"  ##
Recommended
    "wfs_srs"               "EPSG:42304 EPSG:42101 EPSG:4269 EPSG:4326"  ##
Recommended
    #"ows_schemas_location" "http://ogc.dmsolutions.ca"  ## Optional
  END
END

PROJECTION
  "init=epsg:4326"
END

LAYER
  NAME "state"
  METADATA
    "wfs_title"    "state" ## REQUIRED
    "gml_featureid" "ID" ## REQUIRED
    "gml_include_items" "all"  ## Optional (serves all attributes for layer)
  END
  TYPE POLYGON
  STATUS DEFAULT
  DATA state
  PROJECTION
    "init=epsg:4326"
  END
  DUMP TRUE           ## REQUIRED
  CLASS
    NAME "state"
    STYLE
      COLOR 200 255 0
      OUTLINECOLOR 120 120 120
    END
    #TEMPLATE "Demo_query_body_state.html"
  END
END # Layer

END # Map File

The second mapfile is the one about which I had made this post.I had
struggled a lot with this since yesterday.
Finally it started working after making a lot of changes.

The second mapfile is given below:

# Map file created from QGIS project file D:/QGIS
1.3/projects/delhi_trial.qqs.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME Delhi1_postgres.map
  # Map image size
  SIZE 600 600
  UNITS METERS
  SYMBOLSET 'C:\ms4w\Apache\htdocs\Delhi\Symbols.sym'
  FONTSET 'C:\ms4w\Apache\htdocs\Delhi\fonts.txt'
  EXTENT 76.507859 27.613907 78.439621 28.941223
  CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
  IMAGECOLOR 192 192 192

  # Background color for the map canvas -- change as desired
  
  
  # Legend
 
  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH "/ms4w/tmp/ms_tmp/"


    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL "/ms_tmp/"


    # WMS server settings
    METADATA
    "wfs_title"            "GMap WFS Demo Server"  ## REQUIRED
    "wfs_onlineresource"   "http://127.0.0.1/cgi-bin/mapserv.exe?"  ##
Recommended
    "wfs_srs"               "EPSG:42304 EPSG:42101 EPSG:4269 EPSG:4326"  ##
Recommended
    #"wfs_request_method"    "GET"
    #'queryable'          'true'
    #"wfs_feature_info_mime_type" "gml"
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See
MapServer documentation
  END

  LAYER
    CONNECTIONTYPE postgis
		CONNECTION "host=localhost dbname=DelhiDB user=postgres password=postgres
port=5432"
		DATA "the_geom FROM delhi_district USING UNIQUE gid USING SRID=4326"

    NAME "delhi_district"
    TYPE POLYGON
    LABELITEM "polygon_nm"
    CLASSITEM "polygon_nm"
     METADATA
        "wfs_title"    "delhi_district" ## REQUIRED
        "wfs_version" "1.0.0"
        #"wfs_srs" "EPSG:4326"
        #"wfs_typename" "delhi_district"
        #"wfs_service" "WFS"
        "wfs_featureid" "Polygon_nm"
        "gml_include_items" "all"

     END
    
    STATUS DEFAULT
    #HEADER   ../templates/Demo_header.html
    #TEMPLATE ../templates/Demo_query_body1.html
    #FOOTER ../templates/Demo_footer.html
     PROJECTION
    "init=epsg:42304"
     END
    DUMP TRUE
    #TRANSPARENCY 100
   
    CLASS
       EXPRESSION 'Ghaziabad' 
       NAME 'Ghaziabad' 
       GROUP 'Ghaziabad'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 255 0 127
       END
    END
    CLASS
       EXPRESSION 'Gautam Buddha Nagar' 
       NAME 'Gautam Buddha Nagar' 
       GROUP 'Gautam Buddha Nagar'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 0 0 255
       END
    END

    CLASS
       EXPRESSION 'North West' 
       NAME 'North West' 
       GROUP 'North West'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 255 0 255
       END
    END
    CLASS
       EXPRESSION 'South West' 
       NAME 'South West' 
       GROUP 'South West'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 255 170 0
       END
    END
    CLASS
       EXPRESSION 'West' 
       NAME 'West' 
       GROUP 'West'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 85 170 255
       END
    END
    CLASS
       EXPRESSION 'New Delhi' 
       NAME 'New Delhi' 
       GROUP 'New Delhi'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 170 170 0
       END
    END
    CLASS
       EXPRESSION 'East' 
       NAME 'East' 
       GROUP 'East'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 170 85 255
       END
    END
    CLASS
       EXPRESSION 'North East' 
       NAME 'North East' 
       GROUP 'North East'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 127 255 185
       END
    END
    CLASS
       EXPRESSION 'North' 
       NAME 'North' 
       GROUP 'North'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 170 0 0
       END
    END
    CLASS
       EXPRESSION 'South' 
       NAME 'South' 
       GROUP 'South'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 255 170 0
       END
    END
    CLASS
       EXPRESSION 'Faridabad' 
       NAME 'Faridabad' 
       GROUP 'Faridabad'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 0 170 255
       END
    END
    CLASS
       EXPRESSION 'Gurgaon' 
       NAME 'Gurgaon' 
       GROUP 'Gurgaon'
       STYLE
         SYMBOL "quadrat" 
         SIZE 2 
         OUTLINECOLOR 0 0 0
         COLOR 0 255 170
       END
    END
END
END

But I have a question.
In the second map file If I put projection as 4326 GetFeature doesn't work
but in the first one it works.
I put the data into the Postgres DB table from shape files and while doing
so I had put srid=4326.This same data is being read by the second map file.
In the case of the first map file although the projection reads 4326, the
getfeature shows the value of 42304.

<gml:MultiPolygon srsName="EPSG:42304">
−
<gml:polygonMember>
−
<gml:Polygon>
−
<gml:outerBoundaryIs>
−
<gml:LinearRing>

Therefore in either case it seems that GetFeature converts projection to
42304 but in case of .shp files it automatic while not so if the datasource
is Postgres.

Your opinion on this.

Thanks a lot.
You have been a great help!!!!!!!!!!!!!!

Keep it like this.

Warm Regards,

Sunny.
-- 
View this message in context: http://n2.nabble.com/WFS-GetFeature-on-Mapserver-doesn-t-work-tp4905757p4907723.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list