Search in sources :

Example 1 with Datum

use of org.opengis.referencing.datum.Datum in project sis by apache.

the class Formatter method appendForSubtypes.

/**
 * Appends the anchor, scope and domain of validity of the given object. Those information are available
 * only for {@link ReferenceSystem}, {@link Datum} and {@link CoordinateOperation} objects.
 */
private void appendForSubtypes(final IdentifiedObject object) {
    final InternationalString anchor, scope;
    final Extent area;
    if (object instanceof ReferenceSystem) {
        anchor = null;
        scope = ((ReferenceSystem) object).getScope();
        area = ((ReferenceSystem) object).getDomainOfValidity();
    } else if (object instanceof Datum) {
        anchor = ((Datum) object).getAnchorPoint();
        scope = ((Datum) object).getScope();
        area = ((Datum) object).getDomainOfValidity();
    } else if (object instanceof CoordinateOperation) {
        anchor = null;
        scope = ((CoordinateOperation) object).getScope();
        area = ((CoordinateOperation) object).getDomainOfValidity();
    } else {
        return;
    }
    appendOnNewLine(WKTKeywords.Anchor, anchor, null);
    appendOnNewLine(WKTKeywords.Scope, scope, ElementKind.SCOPE);
    if (area != null) {
        appendOnNewLine(WKTKeywords.Area, area.getDescription(), ElementKind.EXTENT);
        append(Extents.getGeographicBoundingBox(area), BBOX_ACCURACY);
        appendVerticalExtent(Extents.getVerticalRange(area));
        appendTemporalExtent(Extents.getTimeRange(area));
    }
}
Also used : Datum(org.opengis.referencing.datum.Datum) InternationalString(org.opengis.util.InternationalString) TemporalExtent(org.opengis.metadata.extent.TemporalExtent) SimpleExtent(org.apache.sis.internal.simple.SimpleExtent) VerticalExtent(org.opengis.metadata.extent.VerticalExtent) Extent(org.opengis.metadata.extent.Extent) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) ReferenceSystem(org.opengis.referencing.ReferenceSystem)

Example 2 with Datum

use of org.opengis.referencing.datum.Datum in project sis by apache.

the class DefinitionVerifier method diffCode.

/**
 * Returns a code indicating in which part the two given CRS differ. The given iterators usually iterate over
 * exactly one element, but may iterate over more elements if the CRS were instance of {@code CompoundCRS}.
 * The returned value is one of {@link #METHOD}, {@link #CONVERSION}, {@link #CS}, {@link #DATUM},
 * {@link #PRIME_MERIDIAN} or {@link #OTHER} constants.
 */
private static int diffCode(final Iterator<SingleCRS> authoritative, final Iterator<SingleCRS> given) {
    while (authoritative.hasNext() && given.hasNext()) {
        final SingleCRS crsA = authoritative.next();
        final SingleCRS crsG = given.next();
        if (!Utilities.equalsApproximatively(crsA, crsG)) {
            if (crsA instanceof GeneralDerivedCRS && crsG instanceof GeneralDerivedCRS) {
                final Conversion cnvA = ((GeneralDerivedCRS) crsA).getConversionFromBase();
                final Conversion cnvG = ((GeneralDerivedCRS) crsG).getConversionFromBase();
                if (!Utilities.equalsApproximatively(cnvA, cnvG)) {
                    return Utilities.equalsApproximatively(cnvA.getMethod(), cnvG.getMethod()) ? CONVERSION : METHOD;
                }
            }
            if (!Utilities.equalsApproximatively(crsA.getCoordinateSystem(), crsG.getCoordinateSystem())) {
                return CS;
            }
            final Datum datumA = crsA.getDatum();
            final Datum datumG = crsG.getDatum();
            if (!Utilities.equalsApproximatively(datumA, datumG)) {
                if ((datumA instanceof GeodeticDatum) && (datumG instanceof GeodeticDatum) && !Utilities.equalsApproximatively(((GeodeticDatum) datumA).getPrimeMeridian(), ((GeodeticDatum) datumG).getPrimeMeridian())) {
                    return PRIME_MERIDIAN;
                }
                return DATUM;
            }
            break;
        }
    }
    return OTHER;
}
Also used : SingleCRS(org.opengis.referencing.crs.SingleCRS) Datum(org.opengis.referencing.datum.Datum) GeodeticDatum(org.opengis.referencing.datum.GeodeticDatum) GeneralDerivedCRS(org.opengis.referencing.crs.GeneralDerivedCRS) GeodeticDatum(org.opengis.referencing.datum.GeodeticDatum) Conversion(org.opengis.referencing.operation.Conversion)

Example 3 with Datum

use of org.opengis.referencing.datum.Datum in project collect by openforis.

the class GeoToolsCoordinateOperations method getDescription.

/**
 * It returns a concatenation of datum, aliases and scope
 */
private String getDescription(CoordinateReferenceSystem crs) {
    List<String> parts = new ArrayList<String>();
    // datum
    if (crs instanceof AbstractSingleCRS) {
        Datum datum = ((AbstractSingleCRS) crs).getDatum();
        String datumName = datum.getName().toString();
        parts.add(datumName);
    }
    // aliases
    for (GenericName genericName : crs.getAlias()) {
        parts.add(genericName.toString());
    }
    // scope
    InternationalString scope = crs.getScope();
    if (scope != null && StringUtils.isNotBlank(scope)) {
        parts.add(scope.toString());
    }
    String result = StringUtils.join(parts, "\n");
    return result;
}
Also used : GenericName(org.opengis.util.GenericName) Datum(org.opengis.referencing.datum.Datum) InternationalString(org.opengis.util.InternationalString) ArrayList(java.util.ArrayList) InternationalString(org.opengis.util.InternationalString) AbstractSingleCRS(org.geotools.referencing.crs.AbstractSingleCRS)

Aggregations

Datum (org.opengis.referencing.datum.Datum)3 InternationalString (org.opengis.util.InternationalString)2 ArrayList (java.util.ArrayList)1 SimpleExtent (org.apache.sis.internal.simple.SimpleExtent)1 AbstractSingleCRS (org.geotools.referencing.crs.AbstractSingleCRS)1 Extent (org.opengis.metadata.extent.Extent)1 TemporalExtent (org.opengis.metadata.extent.TemporalExtent)1 VerticalExtent (org.opengis.metadata.extent.VerticalExtent)1 ReferenceSystem (org.opengis.referencing.ReferenceSystem)1 GeneralDerivedCRS (org.opengis.referencing.crs.GeneralDerivedCRS)1 SingleCRS (org.opengis.referencing.crs.SingleCRS)1 GeodeticDatum (org.opengis.referencing.datum.GeodeticDatum)1 Conversion (org.opengis.referencing.operation.Conversion)1 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)1 GenericName (org.opengis.util.GenericName)1