Search in sources :

Example 1 with Envelope2D

use of com.esri.core.geometry.Envelope2D in project sis by apache.

the class ESRI method tryGetEnvelope.

/**
 * If the given object is an ESRI geometry and its envelope is non-empty, returns
 * that envelope as an Apache SIS implementation. Otherwise returns {@code null}.
 *
 * @param  geometry  the geometry from which to get the envelope, or {@code null}.
 * @return the envelope of the given object, or {@code null} if the object is not
 *         a recognized geometry or its envelope is empty.
 */
@Override
final GeneralEnvelope tryGetEnvelope(final Object geometry) {
    if (geometry instanceof Geometry) {
        final Envelope2D bounds = new Envelope2D();
        ((Geometry) geometry).queryEnvelope2D(bounds);
        if (!bounds.isEmpty()) {
            // Test if there is NaN values.
            final GeneralEnvelope env = new GeneralEnvelope(2);
            env.setRange(0, bounds.xmin, bounds.xmax);
            env.setRange(1, bounds.ymin, bounds.ymax);
            return env;
        }
    }
    return null;
}
Also used : Geometry(com.esri.core.geometry.Geometry) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope) Envelope2D(com.esri.core.geometry.Envelope2D)

Aggregations

Envelope2D (com.esri.core.geometry.Envelope2D)1 Geometry (com.esri.core.geometry.Geometry)1 GeneralEnvelope (org.apache.sis.geometry.GeneralEnvelope)1