You can download the source to JTS here: http://jts-topo-suite.svn.sourceforge.net/viewvc/jts-topo-suite/trunk/
Look for: com.vividsolutions.jts.algorithm.CGAlgorithms.java /** * Returns the signed area for a ring. The area is positive if * the ring is oriented CW. */ public static double signedArea(Coordinate[] ring) { if (ring.length < 3) return 0.0; double sum = 0.0; for (int i = 0; i < ring.length - 1; i++) { double bx = ring[i].x; double by = ring[i].y; double cx = ring[i + 1].x; double cy = ring[i + 1].y; sum += (bx + cx) * (cy - by); } return -sum / 2.0; } Larry On Tue, Dec 15, 2009 at 4:49 PM, karthik shravanam < karthikshrava...@gmail.com> wrote: > Hi All, > > Since this is topic of distance, i had a question about the are that shows > up in the toolbar at the bottom along with the distance on the open jump > application,I was wondering if anyone has the code for it so that i can know > how the tool is calculating the area. > > Can you please let me know. > > Thanks for the help in advance. > > > > Thanks > > On Mon, Dec 14, 2009 at 6:46 AM, Larry Becker <becker.la...@gmail.com>wrote: > >> Sorry, it should have been: >> >> { >> import com.vividsolutions.jts.geom.*; >> import com.vividsolutions.jump.feature.*; >> import com.vividsolutions.jump.workbench.model.*; >> >> features= >> wc.getLayerViewPanel().getSelectionManager().getFeaturesWithSelectedItems(); >> Iterator i = features.iterator(); >> if (features.size() == 2){ >> feature = (Feature) i.next(); >> geoOne = feature.getGeometry(); >> feature = (Feature) i.next(); >> geoTwo= feature.getGeometry(); >> htmlFrame = wc.workbench.frame.outputFrame; >> htmlFrame.createNewDocument(); >> htmlFrame.addText("Distance = "+geoOne.distance(geoTwo)); >> wc.workbench.frame.flash(htmlFrame); >> htmlFrame.surface(); >> } >> } >> >> The former script got the distance between the first two features on the >> selected layer. This one uses the two selected items. >> >> Larry >> >> On Mon, Dec 14, 2009 at 8:33 AM, Larry Becker <becker.la...@gmail.com>wrote: >> >>> Hi Jukka, >>> >>> Here is a script that leverages the JTS distance function: >>> >>> { >>> import com.vividsolutions.jts.geom.*; >>> import com.vividsolutions.jump.feature.*; >>> import com.vividsolutions.jump.workbench.model.*; >>> >>> fc = >>> wc.getLayerNamePanel().getSelectedLayers()[0].getFeatureCollectionWrapper(); >>> Iterator i = fc.getFeatures().iterator(); >>> if (i.hasNext()) { >>> feature = (Feature) i.next(); >>> geoOne = feature.getGeometry(); >>> feature = (Feature) i.next(); >>> geoTwo= feature.getGeometry(); >>> htmlFrame = wc.workbench.frame.outputFrame; >>> htmlFrame.createNewDocument(); >>> htmlFrame.addText("Distance = "+geoOne.distance(geoTwo)); >>> wc.workbench.frame.flash(htmlFrame); >>> htmlFrame.surface(); >>> } >>> } >>> >>> regards, >>> Larry >>> >>> >>> On Sun, Dec 13, 2009 at 8:00 AM, Rahkonen Jukka < >>> jukka.rahko...@mmmtike.fi> wrote: >>> >>>> Hi, >>>> >>>> I agree totally with Larry. OpenJump is already a very productive >>>> editing tool. Connecting routines which are used hundreds of times per day >>>> to menu shortcut or toolbar button does not only speed up the work but it >>>> also cuts down the number of errors, and perhaps most important, it makes >>>> the work much less irritating. And it seems to be that a very useful >>>> features can be added by writing a lines of scripting code. I think that we >>>> should have a script library somewhere in OpenJump wiki. As an example I >>>> must create some screen captures about how to use a fine script made by >>>> Larry for assisting in generating Web Coverage Service requests. I also >>>> notised a Jython script for measuring distance between two selected >>>> features >>>> from GvSIG mailing list. Perhaps it could be modified to work with >>>> OpenJump >>>> as well because the real work is done by JTS. Link to this sript is here: >>>> >>>> http://n2.nabble.com/Distance-using-Jython-td4139275.html#a4139275 >>>> >>>> What I am missing most in OpenJump is the ability to write edited data >>>> back to the database. >>>> >>>> -Jukka Rahkonen- >>>> >>>> >>>> Larry Becker wrote: >>>> >>>> >>>> > Thanks for the feedback Michaël and Stefan. In case anyone out there >>>> is >>>> > wondering what is the use of a toolbox that can only reuse existing >>>> menu >>>> > features, it is all about optimizing work flow. I believe we have an >>>> > opportunity to position OpenJump as being the best tool for data >>>> creation >>>> > and editing. The EZ Buttons function furthers that aim by allowing >>>> users to >>>> > optimize repetitive tasks. EZ Buttons can be used in conjunction with >>>> > BeanTools scripting for the creation of custom tools. However, I do >>>> intend >>>> > to eventually revisit Jukka's idea of a quick-and-easy custom data >>>> entry >>>> > tool for ad hoc field digitizing. >>>> >>>> > regards, >>>> > Larry >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Return on Information: >>>> Google Enterprise Search pays you back >>>> Get the facts. >>>> http://p.sf.net/sfu/google-dev2dev >>>> _______________________________________________ >>>> Jump-pilot-devel mailing list >>>> Jump-pilot-devel@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>> >>> >>> >>> >>> -- >>> Larry Becker >>> Integrated Systems Analysts, Inc. >>> >> >> >> >> -- >> Larry Becker >> Integrated Systems Analysts, Inc. >> >> >> ------------------------------------------------------------------------------ >> Return on Information: >> Google Enterprise Search pays you back >> Get the facts. >> http://p.sf.net/sfu/google-dev2dev >> >> _______________________________________________ >> Jump-pilot-devel mailing list >> Jump-pilot-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >> >> > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and > easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > -- Larry Becker Integrated Systems Analysts, Inc.
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel