Solution for OGR Virtual polygon data

Mark Adams markadams at CUESTASYS.COM
Mon Feb 20 06:43:36 PST 2006


- apologies - accidentally sent the previous email before I'd completed it -


For the benefit of anyone else trying to use this functionality, I also
discovered that you could create a multi-polygon as follows:

POLYGON((x y,...),(x y, ...))

I think this is *supposed* to be a polygon with holes, but in my experience
this displayed as multiple polygons. Fortunately in my app I don't need to
worry about holes....

Thanks everyone for the help in resolving the OGR polygon data issues.

------------------------------
Mark Adams
Senior Analyst & Project Manager
Cuesta Systems (DPRA Canada)
5230 South Service Road
Burlington, ON L7L 5K2
Phone: 905-333-4544 x14
Fax: 905-333-0455
Email: mark.adams at dpra.com


-----Original Message-----
From: Emil Zegers [mailto:taatuut at planet.nl] 
Sent: February 13, 2006 4:28 PM
To: Mark Adams; MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Solution for OGR Virtual polygon data

Hello Mark,

The solution for your problem lies in the format of the polygon data.

You should use:

POLYGON (( 501453.34 4800585.97, 501576.14 4800590.44, 501569.85 4800522,
501471.61 4800521.63, 501453.34 4800585.97 ))

Instead of the format you used.

I got it working that way.

Regards,

Emil


-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
Behalf Of Mark Adams
Sent: donderdag 9 februari 2006 22:11
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] OGR Virtual


Well, I've tried it and this is what I found:
-adding a Projection statement in the MAP file changed nothing. I added
PROJECTION elements to each layer, and played around with changing layers to
different projections - the other layers all worked fine, reprojection
worked fine etc.
-adding the EPSG in the OVF file *finally* generated an error:
[MapServer Error]: msOGRFileOpen(): Open failed for OGR connection
`parcel_test.ovf'.
Failed to import LayerSRS `EPSG:26917'.

The OVF file now looks like this:
<OGRVRTDataSource>
    <OGRVRTLayer name="parcel_test">
        <SrcDataSource>ODBC:parcel_test,PROPERTY_VIRTUAL</SrcDataSource>
 	<SrcSQL>SELECT GEOMETRY FROM PROPERTY_VIRTUAL</SrcSQL>
	<GeometryType>wkbPolygon</GeometryType>
	<GeometryField encoding="WKT" field="GEOMETRY"/>
	<LayerSRS>EPSG:26917</LayerSRS>
    </OGRVRTLayer>
</OGRVRTDataSource>

I don't know why this would fail: the epsg file in proj\nad folder has this
code defined, and mapserver is able to use it for the other layers (which
are shapefiles).

Any thoughts?

Thanks for your help so far.

------------------------------
Mark Adams
Senior Analyst & Project Manager
Cuesta Systems (DPRA Canada)
5230 South Service Road
Burlington, ON L7L 5K2
Phone: 905-333-4544 x14
Fax: 905-333-0455
Email: mark.adams at dpra.com


-----Original Message-----
From: Emil Zegers [mailto:taatuut at planet.nl]
Sent: February 9, 2006 3:57 PM
To: Mark Adams; MAPSERVER-USERS at LISTS.UMN.EDU
Subject: RE: [UMN_MAPSERVER-USERS] OGR Virtual

Hello Mark,

You are correct with your explanation about PROJECTION but since I had this
case last year where I did have to add PROJECTION to an OVF layer although
all data was in the same projection I thought it might be worth trying it.

However, I have not fully test cased this and I don't know enough about the
underlying code to be sure this was the (right) solution to the problem.

Regards,

Emil

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
Behalf Of Mark Adams
Sent: donderdag 9 februari 2006 21:44
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] OGR Virtual


I will try that. However, my understanding of PROJECTION is that it is not
required unless you have data in more than one projection, or want to
display the data in a projection different from the one the data is in. Is
that not correct?

Thanks.

------------------------------
Mark Adams
Senior Analyst & Project Manager
Cuesta Systems (DPRA Canada)
5230 South Service Road
Burlington, ON L7L 5K2
Phone: 905-333-4544 x14
Fax: 905-333-0455
Email: mark.adams at dpra.com


-----Original Message-----
From: Emil Zegers [mailto:taatuut at planet.nl]
Sent: February 9, 2006 3:41 PM
To: Mark Adams; MAPSERVER-USERS at LISTS.UMN.EDU
Subject: RE: [UMN_MAPSERVER-USERS] OGR Virtual

Hello Mark,

Have you tried adding a PROJECTION to the LAYER containing the ovf file
and/or the ovf file?

Something like:

  LAYER
    NAME "Virtual Parcel"
    DEBUG ON
    STATUS DEFAULT
    CONNECTIONTYPE OGR
    CONNECTION "parcel_test.ovf"
    DATA "parcel_test"
    TYPE POLYGON
    # fill projection parameter, e.g. 28992 for Dutch system
    PROJECTION
	"init=epsg:12345"
    END
    TEMPLATE "null"
    CLASS
      NAME "Virtual Parcel"
      STYLE
        COLOR 255 1 5
        OUTLINECOLOR 168 112 0
      END
    END
  END


In the past I had situations where I needed to put the PROJECTION in the
LAYER and not in the OVF file.

Also, use STATUS DEFAULT for testing purposes so the layer is always on.

Regards,

Emil


-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
Behalf Of Mark Adams
Sent: donderdag 9 februari 2006 21:12
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] OGR Virtual


Hello,

I would like to know if there was ever a successful resolution to Frank's
question below. I am in the same situation: I cannot get the OGR virtual
layer to render on my map.

I have had no problem with points. However when I try to render a virtual
polygon I get no error, just no feature on the map. The other layers all
render without problem. I get no error from OGRINFO either.

I've tried a number of different ways of configuring the OVF file, the
data in the database, and the MAP file. Numerous combinations result
in "success" in the sense of no errors, but still no features.

Here is my most recent attempt:
Connection: I'm using an ODBC connection to an MS Access database. The
ODBC connection is called "parcel_test".

OVF:
<OGRVRTDataSource>
    <OGRVRTLayer name="parcel_test">
        <SrcDataSource>ODBC:parcel_test,PROPERTY_VIRTUAL</SrcDataSource>
  <SrcSQL>SELECT GEOMETRY FROM PROPERTY_VIRTUAL</SrcSQL>
 <GeometryType>wkbPolygon</GeometryType>
 <GeometryField encoding="WKT" field="GEOMETRY"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

MAP:
  LAYER
    NAME "Virtual Parcel"
    DEBUG ON
    STATUS ON
    CONNECTIONTYPE OGR
    CONNECTION "parcel_test.ovf"
    DATA "parcel_test"
    TYPE POLYGON
    TEMPLATE "null"
    CLASS
      NAME "Virtual Parcel"
      STYLE
        COLOR 255 1 5
        OUTLINECOLOR 168 112 0
      END
    END
  END

I've got one record in the PROPERTY_VIRTUAL table, with the GEOMETRY value
set as follows:
POLYGON('501453.34 4800585.97,501576.14 4800590.44,501569.85
4800522,501471.61 4800521.63,501453.34 4800585.97')

I've also tried storing the geometry without the quotes, brackets, and
keyword POLYGON but it doesn't change the result.



More information about the MapServer-users mailing list