[mapguide-users] Insert a Point in MapGuide map
ar_gaeta
ar_gaeta at yahoo.it
Fri Nov 26 08:45:20 EST 2010
The problem that I have is insert a point in a existing feature source loaded
into a map.
I've look in a lot of manuals and discussions, principally:
1-http://www.osgeo.org/files/mapguide/docs/webapi/d1/d60/class_mg_point.htm
2-http://svn.osgeo.org/mapguide/trunk/MgDev/Common/Geometry/AgfReaderWriter.h
3-http://augiru.augi.com/content/library/au07/data/paper/DE205-3.pdf
4-http://www.osgeo.org/pipermail/mapguide-users/2007-September/009023.html
But I'm not able to achieve that and I don't understand where is the
problem.
Premises:
-the feature where I want to insert the new element came from a shpfile and
it's stored inside the server, and is writable. The name of the layer is
""pti_23032"" and has 2 fields obligatory to modify: "Geometry" and
"FeatId";
-I launch the script directly from the taskpane of my Ajax layout;
-I have access to the map as Administrator;
-I use MGOS 2.2 in php/java
This is the code that I'm using to try to insert a "static" point to the
map. It doesn't give me any error, but it doesn't create the point too! I
attach it
Thanks in advance for your help.
http://osgeo-org.1803224.n2.nabble.com/file/n5777309/draw_point.jsp
draw_point.jsp
(I write here the "core" part of my code):
//Specify the property values
MgPropertyCollection properties = new MgPropertyCollection();
MgAgfReaderWriter agfWriter = new MgAgfReaderWriter();
//Proviamo a creare il punto acquisendo le coordinate:
MgGeometryFactory geoFactory = new MgGeometryFactory();
double x = Double.parseDouble(coods[0]);
double y = Double.parseDouble(coods[1]);
MgCoordinate coordinate = geoFactory.CreateCoordinateXY(x, y);
MgPoint point = geoFactory.CreatePoint(coordinate);
//Proviamo con queste righe prese dal forum salvato sul desktop...niente:
MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
String pointstring = "POINT XY (" + Double.toString(x) + " " +
Double.toString(y) + ")";
MgGeometry geometry = (MgPoint) wktReaderWriter.Read(pointstring);
MgByteReader geometryByteReader = agfWriter.Write(geometry);
properties.Add(new MgGeometryProperty("Geometry", geometryByteReader));
properties.Add(new MgInt32Property("FeatId", 6));
MgInsertFeatures insertFeature1 = new MgInsertFeatures(layername,
properties);
MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
commands.Add(insertFeature1);
//Per eseguire il comando--In realtà non serve ad un cazzo questa variabile
"layer"...:
MgLayer layer = (MgLayer)map.GetLayers().GetItem(layername);
featureService.UpdateFeatures(fdo, commands, false);
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Insert-a-Point-in-MapGuide-map-tp5777309p5777309.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list