MapServer / MapServer-import

3 stars 2 forks source link

WFS not working as expected for Multi-point Postgis table #1409

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: h.viola@bom.gov.au Date: 2005/07/07 - 02:14

I've posted this on the MapServer users list (and had no reply) twice, so
thought I should just log it as a bug. 

It regards reading a PostGIS table of type MULTIPOINT into
MapServer and providing a WFS, containing the Multipoint data type within
GML <gml:MultiPoint>.

I have undertaken the following steps

1. Created a multipoint shapefile
2. Loaded the multipoint shapefile into PostGIS as a MULTIPOINT table
3. Read and displayed the shapefile into MapServer as a POINT layer
4. Read and displayed the PostGIS MULTIPOINT table into MapServer as a POINT
layer
5. Accessed the multipoint shapefile layer via WFS and successfully received
back <gml:MultiPoint> data with many <gml:Point> entries.
 BUT
6. When accessing the MULTIPOINT PostGIS layer via WFS, the GML returned was
unfortunately not MULTIPOINT GML. It returned only the first point in each
section of data as a single point entry <gml:Point>, so that most of the
data was missing from the WFS output (even though it all displayed ok when
visualised in MapServer).

This address gives an example of WFS, which should show several points per
multipoint entry, but only includes one entry for each <rain_level> value:
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv?map=/web/htdocs/mapserver/radar_wfs.map&version=1.0.0&service=WFS&request=GetFeature&typename=radarseaus

Is this a bug that could be fixed?

Thank you for your time
Hester
h.viola@bom.gov.au
tbonfort commented 12 years ago

Author: sdlime Date: 2005/07/11 - 18:24

What does the mapfile snippet look like for that layer? There were siginificant 
changes in how GML is produced in 4.6. You may simply need to add another 
metadata element...

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/07/20 - 05:49

Hi Steve,

If you can advise on extra Metadata that may make a Multipoint Postgis layer
work for WFS, that would be terrific
This is the code I tried in MS and receive a single GML point for each
rain_level value, even though there should be many.
#######################
#Radar (latest)
LAYER
  CONNECTIONTYPE postgis
  NAME "radarseaus"
  GROUP "Weather Data"
  CONNECTION "host=www4.bom.gov.au user=bom password=bom    dbname=spatial_data"
  DATA "the_geom from tbl_idr_seaus"
  STATUS ON
  TYPE POINT
  TRANSPARENCY 50
  SYMBOLSCALE 3000000
  DUMP TRUE # For WFS server
  CLASSITEM "rain_level"
  CLASS
    EXPRESSION ([rain_level] = 1)
    COLOR 245 245 255
    symbol 3
    MAXSIZE 50
    MINSIZE 2

  END
  CLASS
    EXPRESSION ([rain_level] = 15)
    COLOR 40 0 0
    symbol 3
    MAXSIZE 50
    MINSIZE 2
  END
  METADATA
      WMS_TITLE "Radar for SE Australia"
      WMS_ABSTRACT "Radar (16-level) imagery for SE Australia"
      WMS_SRS "EPSG:4283"
      wms_group_title "Weather Data"
      WFS_TITLE "Radar for SE Australia"
      WFS_ABSTRACT "Radar (16-level) imagery for SE Australia"
      WFS_SRS "EPSG:4283"
  END
END

########################################3

Thanks
tbonfort commented 12 years ago

Author: sdlime Date: 2005/07/25 - 19:40

I wonder if PostGIS advertises multipoint features correctly back to MapServer. 
Do you have the ability to set this up using a multipoint shapefile?

I just got back from holiday and will do some investigation on this end shortly.

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/07/26 - 01:56

Hi Steve, 
Thanks for continuing with this. 

WFS of multipoint shapefile:-
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv?map=/web/htdocs/mapserver/radar_wfs.map&version=1.0.0&service=WFS&request=GetFeature&typename=radarmultipoint
Raw data shapefile is at:-
http://www4.bom.gov.au/mapserver/spatial_data/shapefiles/weather_data/IDR_SEAUS.shp
WFS of equivalent data in postgis:-
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv?map=/web/htdocs/mapserver/radar_wfs.map&version=1.0.0&service=WFS&request=GetFeature&typename=radarseaus
tbonfort commented 12 years ago

Author: sdlime Date: 2005/08/01 - 18:56

Ok, I did find a problem with multipoint output. The goemetry container was not 
being closed properly. I did not have any problem with the multiple points not 
showing up, not with the shapefile anyway. Here's the mapfile I used:

MAP
  NAME TEST
  UNITS DD
  EXTENT 137.692688 -43.087616 148.003159 -35.100861

  WEB
    METADATA
      wfs_title                         "Bug 1409"
      wfs_abstract                      "Test server for bug 1409."
      wfs_srs                           "EPSG:4269"
      wfs_onlineResource                "http://noah.dnr.state.mn.us/cgi-
bin/mapserv48?map=/home/stlime/tmp/wfs/test.map"      
      wfs_namespace_prefix              "test"
      wfs_namespace_uri                 "http://noah.dnr.state.mn.us/test"
    END
  END

  LAYER
    NAME "multipoint1"
    TYPE POINT

    DATA "IDR_SEAUS"
    DUMP TRUE

    # projection
    PROJECTION
      "+init=epsg:4269"
    END

    # metadata
    METADATA
      wfs_title "Sea Surface Temperature"
      wfs_abstract "A sample mulipoint dataset."
      wfs_keywordlist "tempature, ocean"
      gml_include_items "all"
      gml_geometries "stations"
      gml_stations_type "multipoint"        
      #gml_stations_type "point"
      #gml_stations_occurances "0,UNBOUNDED"
    END
  END
END 

Note the extra bit of metadata. That allows you to define an element to hold 
the geometry (e.g. stations) and to define the type of that element (e.g. 
multipoint). You can define mixed geometry types this way, for example some 
polygons and some multipolygons. However most of the time you'll just define 
one. You can also control how multithings are handled. For example, if you were 
to use the commented out metadata above you'd get a bunch of stations each with 
only 1 point.

You don't need this metadata though. MapServer will create a default container 
(msGeometry) and use whatever GML construct that makes sense. Works for GML2 or 
GML3 output

You can see the output from my server at:

  http://noah.dnr.state.mn.us/cgi-bin/mapserv48?
map=/home/stlime/tmp/wfs/test.map&service=WFS&version=1.0.0&request=getFeature&t
ypename=multipoint1&outputformat=GML3

I have updated both CVS HEAD (4.7/4.8) and the 4.6 branch with my fix.

Steve
tbonfort commented 12 years ago

Author: dmorissette Date: 2005/08/01 - 19:44

Reassigned bug to Steve. Can the bug be marked as fixed now?
tbonfort commented 12 years ago

Author: sdlime Date: 2005/08/01 - 19:58

I'd like confirmation from the user first, but otherwise this one's done.

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/08/30 - 06:50

Hi,

AFter further testing and playing around, this issue does not appear to be
resolved I'm afraid. 
I put in the extra metadata as suggested and have installed MS4.7, but the
problem remains. 

The shapefile is represented correctly in GML with appropriate <gml:Point>
entries for each <gml:MultiPoint srsName="EPSG:4283"> within the feature members
- see:
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv4.7?map=/web/htdocs/mapserver/radar_wfs.map&version=1.0.0&service=WFS&request=GetFeature&typename=radarmultipoint

But from the PostGIS table, the multipoint information is still lost - see:
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv4.7?map=/web/htdocs/mapserver/radar_wfs.map&version=1.0.0&service=WFS&request=GetFeature&typename=radarnsw
with only a single <gml:Point srsName="EPSG:4283"> showing in the GML for each
collection of attributes.

I would really appreciate any more help you can offer. We're keen to persist
with PostGIS. 

Thanks
Hester
tbonfort commented 12 years ago

Author: sdlime Date: 2005/08/30 - 15:48

And if you use the multipoint shapefile?

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/08/31 - 01:58

Hi again Steve,

Yes it works as expected with a shapefile,
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv?map=/web/htdocs/mapserver/radar_wfs.map&version=1.0.0&service=WFS&request=GetFeature&resultformat=GML3&typename=radarmultipoint

but we are using PostGIS for our data and would like to make it work as expected
from the database. 

If there is anything you can do, it would be greatly appreciated. 

Thanks
tbonfort commented 12 years ago

Author: sdlime Date: 2005/08/31 - 05:49

Need to get Paul Ramsey in on this one then since it's not really a WFS issue
(may be a query problem). Can you draw the multipoints from PostGIS or do you
just see the single point. Try drawing using shp2img...

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/08/31 - 07:18

Hi,

We have not had any problems symbolising the Multipoint data from PostGIS. It
works in the CGI with html template and via WMS

eg 
http://www4.bom.gov.au/cgi-bin/mapserver/mapserv?map=/web/htdocs/mapserver/weather.map&version=1.1.3&service=WMS&request=GetMap&layers=radarseaus,radarwa,radarnsw,radarnt&bbox=140,-40,160,-20
tbonfort commented 12 years ago

Author: sdlime Date: 2005/08/31 - 17:22

Is there any chance I could access your PostGIS server from here for testing?

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/09/01 - 01:42

Hi Steve,

I'm not really clear whether you need to access the PostGIS data via a .map file
or if you're asking to actually log on to the server www4.bom.gov.au to use psql
and view the multipoint tables that way?
If you just require access to the multipoint  tables via a .map file then the
details below will help. 
Otherwise perhaps we can discuss it directly via email and I will see if we can
provide a read-only login for you to use temporarily. 

The details are as follows:
LAYER
  CONNECTIONTYPE postgis
  NAME "radarnsw"
  GROUP "Weather Data"
  CONNECTION "host=www4.bom.gov.au user=bom password=bom dbname=spatial_data"
  DATA "the_geom from tbl_idr_nsw"
  STATUS ON
  TRANSPARENCY 50
  TYPE POINT
  SYMBOLSCALE 3000000
  DUMP TRUE # For WFS server
  CLASSITEM "rain_level"
  etc ...
an example of the symbols used is in the following text file. 
http://www4.bom.gov.au/mapserver/archive/radar_nsw.txt
Be aware though, there is not much rain around at the moment so this table might
be very small. Other tables you could try are as follows tbl_idr_sa,
tbl_idr_qld, tbl_idr_nt, tbl_idr_wa or tbl_idr_seaus.

Thanks for your time on this.
tbonfort commented 12 years ago

Author: sdlime Date: 2005/09/01 - 04:21

Disregard that request. I set up a PostGIS server today and can test with that.
We're an SDE shop *sigh* so I didn't have anything to test with until today.
I'll see if I can find some time yet this week to fix this.

Steve 
tbonfort commented 12 years ago

Author: sdlime Date: 2005/09/03 - 08:35

I am working on this. Getting friggin' xerces working on a mac, so ogr compiles,
so wfs support works is a pain. Hopfully this weekend.

Steve
tbonfort commented 12 years ago

Author: sdlime Date: 2005/09/03 - 19:48

Ok, I've replicated the error here. Appears to be PostGIS specific. More soon...

Steve
tbonfort commented 12 years ago

Author: sdlime Date: 2005/09/04 - 22:28

Flexibility has it's problems I guess. There are apprarently 2 ways that
multipoint features are stored. In one you define a single linestring with
multiple points and in the other, multiple linestrings each with a single point.
The PostGIS driver does the latter, the shapefile driver the former. The drawing
routines allow for both. The GML writer(s) do not, so I've updated them to do
so.  The change has only been made to the development version. I'll back port
once the fix is confirmed to work in 4.7. 

This is not a problem with the PostGIS driver...

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/09/06 - 06:53

Thanks Steve,
We are just about to grab the CVS update and will let you know whether that is
successful.
Cheerio
Hester 
tbonfort commented 12 years ago

Author: sdlime Date: 2005/09/21 - 05:51

Well, no news is good news I guess. Closing...

Steve
tbonfort commented 12 years ago

Author: h.viola@bom.gov.au Date: 2005/09/22 - 00:54

Thanks Steve, all is good