![]() |
Problem adding points to empty ILineString |
Post Reply
|
| Author | |
rajeev.sood
Visitor
Joined: November 08 2010 Location: United States Status: Offline Points: 7 |
Post Options
Thanks(0)
Quote Reply
Topic: Problem adding points to empty ILineStringPosted: June 13 2011 at 9:43pm |
|
In TE v6: I'm trying to create a new polyline programmatically by drawing on the map (using lbutton down and up), and I initialize the Polyline with an empty ILineString which I created by passing a WKS of "LINESTRING EMPTY" to the geometry creator. Then, on L mouse down I retrieve the ITerrainPolyline6 and grab the Geometry object from it (which is an ILineString). I tried a StartEdit, Points.AddPoint, EndEdit sequence and got back an error that a polyline could only have 0 or >1 points. OK, makes sense. I tried again, but this time tried a StartEdit, Points.AddPoint, Points.AddPoint, EndEdit sequence, which created 2 points and figured I should be good as the EndEdit act as a hint to perform validation on the edit. But, it still fails for the same reason. Is this a bug, or expected behavior? Should I just make a new geometry object when I actually have the data? I didn't try it, but I'm going to guess that this could still be problematic in the case of a ILineString.SetEmpty call as any attempt to add a point after that would create the same behavior. Why not just check the number of points on the EndEdit to enforce the >1 point rule? or when the number of points is 1 just double that first point to prevent the problem (and then remove on second real point add)? I'm going to guess that polygons will have the same problem, although it will probably be 0 or >2. Raj Sood GDIT
|
|
![]() |
|
wengel
Skyline Admin Group
Joined: June 08 2007 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
Posted: June 16 2011 at 8:32pm |
|
Thanks for your question,
currently (TE6,TE601) the first example code is working and the
second is not currently available. //Example 1: geometry created, changed and then attached to a
polyline object. function CreatePolyline1() {
var geometry =
globe.Creator.GeometryCreator.CreateGeometryFromWKT("LINESTRING
EMPTY");
geometry.StartEdit();
geometry.Points.AddPoint(40,40,0);
geometry.Points.AddPoint(80,45,0);
teTerrainObj =
globe.Creator.CreatePolyline(geometry.EndEdit());
} //Example 2: geometry created, attached to a polyline object and
then changed. function CreatePolyline2() {
var geometry = globe.Creator.GeometryCreator.CreateGeometryFromWKT("LINESTRING
EMPTY");
polyline =
globe.Creator.CreatePolyline(geometry);
polyline.geometry.StartEdit();
polyline.geometry.Points.AddPoint(40,40,0);// here you get an error
("LineString < 2")
polyline.geometry.Points.AddPoint(80,45,0);
polyline.geometry =
polyline.geometry.EndEdit();
} Example number 2 should be available in TE6.1. For now, I hope example one suits your needs. |
|
![]() |
|
rajeev.sood
Visitor
Joined: November 08 2010 Location: United States Status: Offline Points: 7 |
Post Options
Thanks(0)
Quote Reply
Posted: June 16 2011 at 9:38pm |
|
Thanks Wilson.
I ended up implementing the first method after asking the question as a workaround until the latter method works.
Raj |
|
![]() |
|
Post Reply
|
|
|
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |