[Gvsig_english] Multipart geometries editing

Francisco José Peñarrubia fpenarru at gmail.com
Tue Feb 2 09:08:14 CET 2010


Hi Flavio.

You have to options: slow and quick, easy and a bit more difficult.
The easy and slow is to convert your IGeometry to JTS Geometry with 
method "toJTS".
The quick is to use PathIterator. You can see code from extCAD => 
IntersectionPointSnapper. Have a look to method getLineIntersection to 
see an example:

    public ArrayList getLineIntersection(IGeometry g, Coordinate c, 
double tol) {
        // return gp.intersects(r);
        // Más exacto
        boolean bool = false;
        ArrayList lineSegments = new ArrayList();
        int theType;
        // Use this array to store segment coordinate data
        double[] theData = new double[6];
        PathIterator theIterator;

        theIterator = g.getPathIterator(null, FConverter.FLATNESS);
        ArrayList arrayCoords = new ArrayList();
        while (!theIterator.isDone()) {
            theType = theIterator.currentSegment(theData);
            if (theType == PathIterator.SEG_MOVETO) {
                arrayCoords.add(new Point2D.Double(theData[0], theData[1]));
            } else if (theType == PathIterator.SEG_LINETO) {
                arrayCoords.add(new Point2D.Double(theData[0], theData[1]));
                Point2D pAnt = (Point2D) arrayCoords
                        .get(arrayCoords.size() - 2);
                LineSegment l = new LineSegment(pAnt.getX(), pAnt.getY(),
                        theData[0], theData[1]);
                if (l.distancePerpendicular(c) < tol) {
                    bool = true;
                    lineSegments.add(l);
                }
            } else if (theType == PathIterator.SEG_CLOSE) {
                Point2D firstPoint = (Point2D) arrayCoords.get(0);
                Point2D pAnt = (Point2D) arrayCoords
                        .get(arrayCoords.size() - 1);
                LineSegment l = new LineSegment(pAnt.getX(), pAnt.getY(),
                        firstPoint.getX(), firstPoint.getY());
                if (l.distancePerpendicular(c) < tol) {
                    bool = true;
                    lineSegments.add(l);
                }
            }
            theIterator.next();
        }
        return lineSegments;
    }

Hope this helps.

Fran Peñarrubia
www.scolab.es

Flavio Pompermaier escribió:
> Thank you all for the quick replies,
> but unfortunately I need parts enlighting, also if the multi-part 
> geometry is not splitted into many parts.
> I think I'll implement such a functionality but I don't know where to 
> start..could someone give me some hint and
> save me some work...??
>
> Thanks in advance,
> Flavio
>
> 2010/2/1 Simon Cropper (Botanicus Australia Pty Ltd) 
> <scropper at botanicusaustralia.com.au 
> <mailto:scropper at botanicusaustralia.com.au>>
>
>     Flavio,
>
>     gvSIG does not have the ability to split multi-part polygons so
>     each of
>     the "parts" can be manipulated seprately.
>
>     The Sextante 0.5 Plug-in has a routine though called "Separate
>     multi-part features" under the menu "Tools for Cector layers".
>
>     This creates a new file where any multi-part polygon is split into its
>     component parts.
>
>     If you do not have Sextante 0.5 running you can find the instructions
>     for installation here...
>     https://gvsig.org/web/projects/contrib/community-doc/pub/test-docs/getting-sextante-0-5-to-work-with-gvsig-version-1-9-bn-1253/
>
>     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>
>     <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>
>
>
>     On 2/02/2010 3:13 AM, Flavio Pompermaier wrote:
>     > Hi to all,
>     > I'd like to know if anybody has ever encountered the problem I
>     have to
>     > face with: I've multipart geometries on which I must do some work on
>     > theri single parts,
>     > like reordering, enlighting, union, splitting and similar stuff.
>     Does
>     > gvSIG have the knowledge of "parts" concept from an editing
>     point of view?
>     > Could it be introduced without a great effort? And if so, where
>     should
>     > I start from with the code?
>     >
>     > Any help is appreciated!
>     > Flavio
>     >
>     >
>     > _______________________________________________
>     > Gvsig_internacional mailing list
>     > Gvsig_internacional at listserv.gva.es
>     <mailto: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
>     <mailto: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
>   



More information about the Gvsig_internacional mailing list