src/main/java/com/esri/core/geometry/OperatorProject.java
public static Geometry foldInto360Range(Geometry geom, SpatialReference pannableSR) {
        Envelope2D envelope2D = new Envelope2D();
        geom.queryEnvelope2D(envelope2D);
        if (envelope2D.xmax <= 180.0 && envelope2D.xmin >= -180.0) {
            return geom;
        }

        // clip by -180 and 180
        MultiPath foldedGeometry = null;

        if (geom.getType() != Geometry.Type.Polyline && geom.getType() != Geometry.Type.Polygon)
            return geom;

        MultiPathImpl multiPath = (MultiPathImpl)geom._getImpl();
        if (geom.getType() == Geometry.Type.Polygon) {
            foldedGeometry = new Polygon(multiPath.m_description);
        } else if (geom.getType() == Geometry.Type.Polyline) {
            foldedGeometry = new Polyline(multiPath.m_description);
        }

        // TODO this should be a static class member
        Polyline cuttee1 = new Polyline();
        cuttee1.startPath(-180, 90);
        cuttee1.lineTo(-180, -90);
        cuttee1.startPath(180, 90);
        cuttee1.lineTo(180, -90);
        Geometry[] parts = GeometryEngine.cut(geom, cuttee1, pannableSR);

        if (parts.length == 0) {
            parts = new Geometry[] {geom};
        }

        for (Geometry geometryPart : parts) {
            geometryPart.queryEnvelope2D(envelope2D);
            // TODO this only accounts for geometries with lat lon rang of -540 to 540
            if (envelope2D.xmin < -180) {
                // add 180 to all vertices in geometry
                // TODO this should be a static class member
                Transformation2D transformation2D = new Transformation2D();
                transformation2D.xd = 360;
                geometryPart.applyTransformation(transformation2D);
            }
            if (envelope2D.xmax > 180) {
                // TODO this should be a static class member
                Transformation2D transformation2D = new Transformation2D();
                transformation2D.xd = -360;
                geometryPart.applyTransformation(transformation2D);
            }
            foldedGeometry.add((MultiPath) geometryPart, false);
        }

        return foldedGeometry;
    }
/**
     * Folds a geometry into the 360 degree range of the associated spatial reference. If the spatial reference be a 'pannable' PROJECTED or GEOGRAPHIC. For other spatial types, the function throws an invalid
     * argument exception. A pannable PROJECTED it a Rectangular PROJECTED where the x coordinate range is equivalent to a 360 degree range on the defining geographic Coordinate System(GEOGRAPHIC). If the spatial
     * reference is a GEOGRAPHIC then it is always pannable(default 360 range for spatial reference in GEOGRAPHIC coordinates is -180 to 180)
     * <p>
     * If the geometry is an Envelope fold_into_360_range returns a polygon, unless the Envelope is empty, in which case the empty envelope is returned. The result geometry will be completely inside of
     * the coordinate system extent. The folding happens where geometry intersects the min or max meridian of the spatial reference and when geometry is completely outside of the min-max meridian range.
     * Folding does not preserve geodetic area or length. Folding does not preserve perimeter of a polygon.
     *
     * @param geom       The geometry to be folded.
     * @param pannableSR The pannable Spatial Reference.
     * @return Folded geometry.
     */
Folds a geometry into the 360 degree range of the associated spatial reference. If the spatial reference be a 'pannable' PROJECTED or GEOGRAPHIC. For other spatial types, the function throws an invalid
argument exception. A pannable PROJECTED it a Rectangular PROJECTED where the x coordinate range is equivalent to a 360 degree range on the defining geographic Coordinate System(GEOGRAPHIC). If the spatial
reference is a GEOGRAPHIC then it is always pannable(default 360 range for spatial reference in GEOGRAPHIC coordinates is -180 to 180)

If the geometry is an Envelope fold_into_360_range returns a polygon, unless the Envelope is empty, in which case the empty envelope is returned. The result geometry will be completely inside of
the coordinate system extent. The folding happens where geometry intersects the min or max meridian of the spatial reference and when geometry is completely outside of the min-max meridian range.
Folding does not preserve geodetic area or length. Folding does not preserve perimeter of a polygon.

@param geom       The geometry to be folded.
@param pannableSR The pannable Spatial Reference.
@return Folded geometry.
Folds a geometry into the 360 degree range of the associated spatial reference . If the spatial reference be a ' pannable ' PROJECTED or GEOGRAPHIC . For other spatial types the function throws an invalid argument exception . A pannable PROJECTED it a Rectangular PROJECTED where the x coordinate range is equivalent to a 360 degree range on the defining geographic Coordinate System ( GEOGRAPHIC ) . If the spatial reference is a GEOGRAPHIC then it is always pannable ( default 360 range for spatial reference in GEOGRAPHIC coordinates is - 180 to 180 ) If the geometry is an Envelope fold_into_360_range returns a polygon unless the Envelope is empty in which case the empty envelope is returned . The result geometry will be completely inside of the coordinate system extent . The folding happens where geometry intersects the min or max meridian of the spatial reference and when geometry is completely outside of the min - max meridian range . Folding does not preserve geodetic area or length . Folding does not preserve perimeter of a polygon . @param geom The geometry to be folded . @param pannableSR The pannable Spatial Reference . @return Folded geometry .
public static Geometry foldInto360Range(Geometry geom, SpatialReference pannableSR) {
        Envelope2D envelope2D = new Envelope2D();
        geom.queryEnvelope2D(envelope2D);
        if (envelope2D.xmax <= 180.0 && envelope2D.xmin >= -180.0) {
            return geom;
        }
        MultiPath foldedGeometry = null;
        if (geom.getType() != Geometry.Type.Polyline && geom.getType() != Geometry.Type.Polygon)
            return geom;
        MultiPathImpl multiPath = (MultiPathImpl)geom._getImpl();
        if (geom.getType() == Geometry.Type.Polygon) {
            foldedGeometry = new Polygon(multiPath.m_description);
        } else if (geom.getType() == Geometry.Type.Polyline) {
            foldedGeometry = new Polyline(multiPath.m_description);
        }
        Polyline cuttee1 = new Polyline();
        cuttee1.startPath(-180, 90);
        cuttee1.lineTo(-180, -90);
        cuttee1.startPath(180, 90);
        cuttee1.lineTo(180, -90);
        Geometry[] parts = GeometryEngine.cut(geom, cuttee1, pannableSR);
        if (parts.length == 0) {
            parts = new Geometry[] {geom};
        }
        for (Geometry geometryPart : parts) {
            geometryPart.queryEnvelope2D(envelope2D);
            if (envelope2D.xmin < -180) {
                Transformation2D transformation2D = new Transformation2D();
                transformation2D.xd = 360;
                geometryPart.applyTransformation(transformation2D);
            }
            if (envelope2D.xmax > 180) {
                Transformation2D transformation2D = new Transformation2D();
                transformation2D.xd = -360;
                geometryPart.applyTransformation(transformation2D);
            }
            foldedGeometry.add((MultiPath) geometryPart, false);
        }
        return foldedGeometry;
    }
public static Geometry foldInto360Range ( Geometry geom , SpatialReference pannableSR ) { Envelope2D envelope2D = new Envelope2D ( ) ; geom . queryEnvelope2D ( envelope2D ) ; if ( envelope2D . xmax <= 180.0 && envelope2D . xmin >= - 180.0 ) { return geom ; } MultiPath foldedGeometry = null ; if ( geom . getType ( ) != Geometry . Type . Polyline && geom . getType ( ) != Geometry . Type . Polygon ) return geom ; MultiPathImpl multiPath = ( MultiPathImpl ) geom . _getImpl ( ) ; if ( geom . getType ( ) == Geometry . Type . Polygon ) { foldedGeometry = new Polygon ( multiPath . m_description ) ; } else if ( geom . getType ( ) == Geometry . Type . Polyline ) { foldedGeometry = new Polyline ( multiPath . m_description ) ; } Polyline cuttee1 = new Polyline ( ) ; cuttee1 . startPath ( - 180 , 90 ) ; cuttee1 . lineTo ( - 180 , - 90 ) ; cuttee1 . startPath ( 180 , 90 ) ; cuttee1 . lineTo ( 180 , - 90 ) ; Geometry [ ] parts = GeometryEngine . cut ( geom , cuttee1 , pannableSR ) ; if ( parts . length == 0 ) { parts = new Geometry [ ] { geom } ; } for ( Geometry geometryPart : parts ) { geometryPart . queryEnvelope2D ( envelope2D ) ; if ( envelope2D . xmin < - 180 ) { Transformation2D transformation2D = new Transformation2D ( ) ; transformation2D . xd = 360 ; geometryPart . applyTransformation ( transformation2D ) ; } if ( envelope2D . xmax > 180 ) { Transformation2D transformation2D = new Transformation2D ( ) ; transformation2D . xd = - 360 ; geometryPart . applyTransformation ( transformation2D ) ; } foldedGeometry . add ( ( MultiPath ) geometryPart , false ) ; } return foldedGeometry ; }
Folds a geometry into the 360 degree range of the associated spatial reference.
Folds a geometry into the 360 degree range of the associated spatial reference .
// clip by -180 and 180 // TODO this should be a static class member // TODO this only accounts for geometries with lat lon rang of -540 to 540 // add 180 to all vertices in geometry // TODO this should be a static class member // TODO this should be a static class member