[URGENT] Need help with Serialize GML

Topics: SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0
Sep 10, 2010 at 7:49 AM
Edited Sep 10, 2010 at 8:07 AM

Hey all.

For a project i need to serialize GML data, so i descided to use the SharpMap.Data.Providers.GML objects to generate the objects.
This turns out to be quitte challenging . 

Given the following XML i need to be able to serialize, i thought it would be as easy as the sample code below. 

<geometrie xsi:type="gml:MultiSurfaceType">
<gml:surfaceMember>
  <gml:Surface>
      <gml:patches>
           <gml:PolygonPatch>
               <gml:exterior>
                     <gml:LinearRing>
                         <gml:posList>236943.00 472519.00 236943.00 472519.00 236944.00 472517.00 236942.00 472517.00 236943.00  472519.00</gml:posList>
   </gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>
</gml:surfaceMember>
<gml:surfaceMember>
   <gml:Surface>
         <gml:patches>
         <gml:PolygonPatch>
           <gml:exterior>
              <gml:LinearRing>
                      <gml:posList>236943.00 472519.00 236943.00 472519.00 236944.00 472517.00 236942.00 472517.00 236943.00 472519.00</gml:posList>
              </gml:LinearRing>
           </gml:exterior>
           </gml:PolygonPatch>
          </gml:patches>
   </gml:Surface>
 </gml:surfaceMember>
</geometrie>

 

Code (all is C#)

               SurfaceMember sm = new SurfaceMember();
                AbstractSurfaceType astSurface = new Surface();

                PosList pl = new PosList();
                 pl.Value = "[valid coords]";
                 AbstractRingType asr = new LinearRing();
                 ((LinearRingType)asr).PosList = pl;
                 AbstractRingPropertyType ext = new Exterior();
                 AbstractSurfacePatchType apt = new PolygonPatch();
                 ((PolygonPatch)apt).Exterior = (Exterior)ext;
                  Patches pt = new Pathes()
                  pt.Add((AbstractSurfacePatch)apt);
                  ((Surface)astSurface).Patches = pt; 
          mst.SurfaceMember.Add(sm); 

 

At the point where i add the Pathes to the Surface i get an error, cant convert SharpMap.Entities.Ogc.Gml.PolygonPatch to SharpMap.Entities.Ogc.Gml.AbstractSurfacePatch 

Any ideas as to accomplish this, i NEED the serializabe objects, and no StringBuilder  or other XmlDocument structures ..

Regards,

 

Gerwin Postma