1

Re: Getting OneSiteData using PolygonBoundary

I've implemented the Web Services on a new site I'm developing and have been attempting to retrieve data which intersects a polygon. I've managed to get it to work for a buffer around a point, but I get the error "The type net.nbnws.www.Point was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically" whenever I try and search using a PolygonBoundary. My code is as follows...

Dim ws As New GatewayWebService()
ws.EnableDecompression = True
Dim req As New OneSiteDataRequest()
req.registrationKey = "0000000000000000000000000000"
Dim gf As New GeographicalFilter()
gf.MinimumResolution = Resolution._1km
gf.MinimumResolutionSpecified = True
Dim CoordsArray() As String
CoordsArray = BufferedRoute.Split(",")
Dim pb As New PolygonBoundary()
Dim coords(UBound(CoordsArray)) As Point
For i As Integer = 0 To UBound(coords)
        Dim pt As New Point()
        pt.srs = SpatialReferenceSystem.osgb_BNG
        pt.x = Math.Round(CInt(CoordsArray(i).Split(" ")(0)))
        pt.y = Math.Round(CInt(CoordsArray(i).Split(" ")(1)))
        coords(i) = pt
Next
pb.Ring = coords
Dim p As New Polygon()
p.srs = SpatialReferenceSystem.osgb_BNG
p.Boundary = pb
gf.Item = p
req.GeographicalFilter = gf
Dim gd As GatewayData = ws.GetOneSiteData(req)

and that last line is where it fails.

Any advice would be gratefully received.

Thanks,

Tim

2

Re: Getting OneSiteData using PolygonBoundary

Anyone?

3

Re: Getting OneSiteData using PolygonBoundary

Hi Tim,

I have tried the code. But without any success either.
But I could never get the same as your. The only SoapException I got was with blank message.
I have modified the code to just do grid square and that works fine.
Is a bug in the web services?

ps. I have only tried the code with DLL. I don't know if it would produce different result with WSDL...

Luck

IT Officer
rECOrd (A Biodiversity Information System for Cheshire, Halton, Warrington and Wirral)
www.record-lrc.co.uk

4

Re: Getting OneSiteData using PolygonBoundary

Thanks Luck.

I'm using the WSDL, as I couldn't get .NET to pick up the DLL.

Hopefully someone from the Web Services team will be able to have a look at this.

Tim

5

Re: Getting OneSiteData using PolygonBoundary

The issue here is that you are building up a Ring from Points rather than Coordinates. This can be seen from the schema of the NBN web services.

The section of the schema which is of particular interest to you is...

<xsd:element name="Ring">
<xsd:annotation>
<xsd:documentation>
A ring of vertices (coordinates). Typically this will be part of a polygon.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="v" type="spatial:Coordinate" minOccurs="3" maxOccurs="unbounded">

Below is the variation of your code which has been tested to work.

 Dim ws As New GatewayWebService()
        ws.EnableDecompression = True
        Dim req As New OneSiteDataRequest()
        req.registrationKey = "-----------------------------"
        req.username = "-----------------------------"
        Dim gf As New GeographicalFilter()
        gf.MinimumResolution = Resolution._1km
        gf.MinimumResolutionSpecified = True
        Dim CoordsArray() As String
        CoordsArray = BufferedRoute.Split(",")
        Dim pb As New PolygonBoundary()
        Dim coords(UBound(CoordsArray)) As Coordinate
        For i As Integer = 0 To UBound(coords)
            Dim pt As New Coordinate()
            pt.srs = SpatialReferenceSystem.osgb_BNG
            pt.x = Math.Round(CInt(CoordsArray(i).Split(" ")(0)))
            pt.y = Math.Round(CInt(CoordsArray(i).Split(" ")(1)))
            coords(i) = pt
        Next
        pb.Ring = coords
        Dim p As New Polygon()
        p.srs = SpatialReferenceSystem.osgb_BNG
        p.Boundary = pb
        gf.Item = p
        req.GeographicalFilter = gf
        Dim gd As GatewayData = ws.GetOneSiteData(req)

Cheers

Christopher Johnson
NBN Developer

6

Re: Getting OneSiteData using PolygonBoundary

I thought that Coordinate couldn't be used as it was only an abstract class. Still, you live and learn!

All seems to be working fine now.

Thanks,

Tim