Hi Jukka,

You can easily pick start and end point with
Geometry geometry = feature.getGeometry();

// this will return something whatever the geometry is
Coordinate[] cc = geometry.getCoordinates();
x_start = cc[0].x;
y_start = cc[0].y;
x_end = cc[cc.length-1].x;
y_end = cc[cc.length-1].y;

// this is more readable if you make sure your geometry is a linestring 
before
LineString lineString = (LineString)feature.getGeometry();
x_start = lineString.getStartPoint().getX();
y_start = lineString.getStartPoint().getY();
x_end = lineString.getEndPoint().getX();
y_end = lineString.getEndPoint().getX();

Warning : I did not check the code

Michaël

PS let us know what you achieved with this code

> Hi,
>
> How could I pick Startpoint_X, Startpoint_Y, Endpoint_X,Endpoint_Y from a 
> linestring with BeanShell? Meaning is to build a http request for an external 
> routing service. Something similar is done in the following code with 
> envelope of a geometry for building a WFS GetFeature request with BBOX filter.
>
> Geometry geometry = feature.getGeometry();
>                  Envelope env = geometry.getEnvelopeInternal();
>                  htmlFrame.addText("wget "
>                          +"\"http://hip.latuviitta.org/cgi-bin/";
>                          +"tinyows?"
>                          +"SERVICE=WFS"
>                          +"&VERSION=1.0.0"
>                          +"&REQUEST=GetFeature"
>                          +"&TYPENAME=lv:municipalities"
>                          +"&BBOX="
>                          +env.getMinX()+","
>                          +env.getMinY()+","
>                          +env.getMaxX()+","
>                          +env.getMaxY()+"\""
>                          +" -O prexif_"
>                          +j
>                          +".gml"  );
>
> -Jukka Rahkonen-
>       
> ------------------------------------------------------------------------------
> Own the Future-Intel® Level Up Game Demo Contest 2013
> Rise to greatness in Intel's independent game demo contest.
> Compete for recognition, cash, and the chance to get your game
> on Steam. $5K grand prize plus 10 genre and skill prizes.
> Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>


------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to