[mapguide-users] Polygon are not recorded in feature

Ivan Milicevic Ivan.Milicevic at supranet.hr
Tue Mar 3 03:30:15 EST 2009



Please, open http://gis.supranet.hr/mapguide/mapagent/index.html click on Resource->GetResourceContent


Maybe your feature source is set to rtead only. I had the same problem in past couple of days.


From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Micho Gar
Sent: Monday, March 02, 2009 6:44 PM
To: MapGuide Users Mail List
Subject: [mapguide-users] Polygon are not recorded in feature


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();

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);
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");


# 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!. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090303/dd2be168/attachment.html

More information about the mapguide-users mailing list