[Gvsig_english] Distance using Jython

Juan Lucas Dominguez Rubio jldominguez at prodevelop.es
Thu Dec 10 08:54:07 CET 2009


Hello, Simon:
 
JTS is briefly mentioned and praised in the credits dialog: 'Help - About - gvSIG tab' (pull down scroll bar). The word 'VividSolutions' does not appear, but there is a direct link to their website.
 
> Can you clarify if gvSIG uses the JTS library?
 
Sure it does. I would rather say that gvSIG was born in the lap of JTS :)
 
Regards,
 
 
 
Juan Lucas Domínguez Rubio
---
Prodevelop SL, Valencia (España)
Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
http://www.prodevelop.es <http://www.prodevelop.es/> 
---

________________________________

De: gvsig_internacional-bounces at listserv.gva.es en nombre de Simon Cropper (Botanicus Australia Pty Ltd)
Enviado el: jue 10/12/2009 5:54
Para: Users and Developers mailing list
Asunto: Re: [Gvsig_english] Distance using Jython



Hi Juan Lucas,

Thanks for the various links. It is filling in a variety of gaps in my
knowledge of java, python and scripting.

I followed your instructions and it work as described.

Can you clarify if gvSIG uses the JTS library. I can't see
acknowledgment of Vivid Solutions in the "About gvSIG" dialog, or is the
library distributed with Java?

Cheers Simon

Simon Cropper
Botanicus Australia Pty Ltd
PO Box 160, Sunshine, Victoria 3020.
P: 9311 5822. M: 041 830 3437.
mailto: scropper at botanicusaustralia.com.au
<mailto:scropper at botanicusaustralia.com.au>
web: www.botanicusaustralia.com.au <http://www.botanicusaustralia.com.au <http://www.botanicusaustralia.com.au/> >



Juan Lucas Dominguez Rubio wrote:
> Hello.
> To compute the distance between two features of the same layer, you
> can do this:
> 
> - Add the layer to the view
> - Set the layer as the only active layer (by clicking on it in the TOC)
> - Select the two features for which you wish to know the distance. You
> must have exactly two features selected
> - Click on the menu option: "File - Scripting - Jython console"
> - Paste this long line:
> 
> import com.iver.andami; import com.iver.andami.ui.mdiManager; v =
> com.iver.andami.PluginServices.getMDIManager().getActiveWindow(); mc =
> v.getMapControl(); mx = mc.getMapContext(); lyrs = mx.getLayers();
> lyract = lyrs.getActives()[0]; selsup = lyract.getSelectionSupport();
> sel = selsup.getSelection(); firstsel = sel.nextSetBit(0); secondsel =
> sel.nextSetBit(firstsel+1); vf = lyract.getSource(); fgeom =
> vf.getShape(firstsel); sgeom = vf.getShape(secondsel); fjtsgeom =
> fgeom.toJTSGeometry(); sjtsgeom = sgeom.toJTSGeometry();
> fjtsgeom.distance(sjtsgeom)
> 
> - Then hit enter and you should see the distance in map units as seen
> here:
> 
> http://www.prodevelop.es/files/fm/public/downloads/images/jython_dist.jpg
> 
> For a more elegant way to do this, see:
> 
> ftp://downloads.gvsig.org/gva/descargas/manuales/gvsig-1_0-scripting-tutorial-v2-en.zip
> 
> I'm not saying this is the only way to do it, though.
> 
> The script shown above uses the distance function implemented in the
> widely used JTS library:
> 
> http://www.vividsolutions.com/Jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#distance(com.vividsolutions.jts.geom.Geometry
> <http://www.vividsolutions.com/Jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#distance%28com.vividsolutions.jts.geom.Geometry>)
> 
> 
> Regards,
> 
> Juan Lucas Domínguez Rubio
> ---
> Prodevelop SL, Valencia (España)
> Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
> http://www.prodevelop.es <http://www.prodevelop.es/>  <http://www.prodevelop.es/>
> ---
> 
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gvsig_internacional mailing list
> Gvsig_internacional at listserv.gva.es
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>  
_______________________________________________
Gvsig_internacional mailing list
Gvsig_internacional at listserv.gva.es
http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.gva.es/pipermail/gvsig_internacional/attachments/20091210/cbca87b7/attachment.htm 


More information about the Gvsig_internacional mailing list