www.skylinesoft.com Homepage
Forum Home Forum Home > SkylineGlobe Enterprise Products > TerraExplorer for Developers
  New Posts New Posts RSS Feed - Problem adding points to empty ILineString
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem adding points to empty ILineString

 Post Reply Post Reply
Author
Message
rajeev.sood View Drop Down
Visitor
Visitor
Avatar

Joined: November 08 2010
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote rajeev.sood Quote  Post ReplyReply Direct Link To This Post Topic: Problem adding points to empty ILineString
    Posted: 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
Back to Top
wengel View Drop Down
Skyline Admin Group
Skyline Admin Group
Avatar

Joined: June 08 2007
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote wengel Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
rajeev.sood View Drop Down
Visitor
Visitor
Avatar

Joined: November 08 2010
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote rajeev.sood Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.188 seconds.