[mapguide-users] Polygon are not recorded in feature
Kenneth Skovhede, GEOGRAF A/S
ks at geograf.dk
Tue Mar 3 03:10:08 EST 2009
The "UpdateFeatures" call does not throw exceptions,
even if the call fails, try to examine the return value,
and search the mailing lists for the exact description.
Regards, Kenneth Skovhede, GEOGRAF A/S
Micho Gar skrev:
> Hi all,
>
> I have a code that should save the polygons in the feature source
> after using the Digitize. In principle I do not give any error, but
> when reviewing the shp the polygon don´t appear. I leave with you the
> code because I don´t see anything bad.
>
> MgUserInformation userInfo = new MgUserInformation(sessionId);
> MgSiteConnection siteConnection = new MgSiteConnection();
> siteConnection.Open(userInfo);
>
> MgResourceService resourceService =
> (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
> MgFeatureService featureService =
> (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
>
> MgResourceIdentifier zonasFeatureId = new
> MgResourceIdentifier("Library://ConectorGPS/Datos/poligonosZonas.FeatureSource");
> MgFeatureCommandCollection zonasComando = new
> MgFeatureCommandCollection();
>
> //Abrimos el mapa
> MgMap mapa = new MgMap();
> mapa.Open(resourceService, mapName);
>
> //creamos la geometria
> MgGeometryFactory geometryFactory = new MgGeometryFactory();
> MgCoordinateCollection coordinateCollection = new
> MgCoordinateCollection();
> //MgLinearRingCollection interiorRingCollection = new
> MgLinearRingCollection();
> MgAgfReaderWriter geometryReaderWriter = new MgAgfReaderWriter();
>
> int count = xCollection.length;
> for(int i=0; i<count;i++)
> {
> Double x = Double.valueOf(xCollection[i]);
> Double y = Double.valueOf(yCollection[i]);
> MgCoordinate coordinate = geometryFactory.CreateCoordinateXY(x,y);
> coordinateCollection.Add(coordinate);
> }
> MgLinearRing exteriorRing =
> geometryFactory.CreateLinearRing(coordinateCollection);
> MgPolygon polygon = geometryFactory.CreatePolygon(exteriorRing,null);
> MgByteReader geom = geometryReaderWriter.Write(polygon);
>
> //creamos una coleccion de propiedades y la insertamos
> MgPropertyCollection propiedades = new MgPropertyCollection();
> propiedades.Add(new MgGeometryProperty("Geometry", geom));
> propiedades.Add(new MgStringProperty("ID", "zona1"));
> zonasComando.Add(new MgInsertFeatures("zonasCapa", propiedades));
>
> featureService.UpdateFeatures(zonasFeatureId, zonasComando, false);
>
> //capturamos la capa para salvar el mapa y refrescar
> MgLayerBase zonasCapa = mapa.GetLayers().GetItem("zonasCapa");
> zonasCapa.SetVisible(true);
> zonasCapa.ForceRefresh();
> mapa.Save(resourceService);
> out.println("finish");
>
>
> Thanks
>
> --
> # michogar
> # Analista Programador SIG
> # Ubuntu Linux Counter 462666
>
>
>
> "Cuenta una leyenda que si reproduces un DVD de Windows Vista original
> al revés se oye a Bill Gates entonando cantos satánicos... Pero eso no
> es lo peor... Si lo reproduces del derecho... ¡Se instala!."
>
>
> "It has a legend that if you play an original Windows Vista DVD
> backwards to hear Bill Gates Satanic chanting songs ... But that's not
> the worst ... If you play it right ... It installs!.
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090303/3410348c/attachment.html
More information about the mapguide-users
mailing list