/** * Tests the {@link VerticalDatumTypes#fromLegacy(int)} method. */ @Test public void testFromLegacy() { assertEquals(VerticalDatumTypes.ELLIPSOIDAL, VerticalDatumTypes.fromLegacy(2002)); assertEquals(VerticalDatumType .GEOIDAL, VerticalDatumTypes.fromLegacy(2005)); assertEquals(VerticalDatumType .DEPTH, VerticalDatumTypes.fromLegacy(2006)); }
/** * Returns the type of this datum, or infers the type from the datum name if no type were specified. * The later case occurs after unmarshalling, since GML 3.2 does not contain any attribute for the datum type. * It may also happen if the datum were created using reflection. * * <p>This method uses heuristic rules and may be changed in any future SIS version. If the type can not be * determined, default on the ellipsoidal type since it will usually implies no additional calculation.</p> * * <p>No synchronization needed; this is not a problem if this value is computed twice. * This method returns only existing immutable instances.</p> * * @see #getVerticalDatumType() * @see #getTypeElement() */ private VerticalDatumType type() { VerticalDatumType t = type; if (t == null) { final ReferenceIdentifier name = super.getName(); type = t = VerticalDatumTypes.guess(name != null ? name.getCode() : null, super.getAlias(), null); } return t; }
/** * Tests the {@link VerticalDatumTypes#toLegacy(VerticalDatumType)} method. */ @Test public void testToLegacy() { assertEquals(2002, VerticalDatumTypes.toLegacy(VerticalDatumTypes.ELLIPSOIDAL)); assertEquals(2005, VerticalDatumTypes.toLegacy(VerticalDatumType .GEOIDAL)); assertEquals(2006, VerticalDatumTypes.toLegacy(VerticalDatumType .DEPTH)); }
VerticalDatumType type = null; if (isWKT1) { type = VerticalDatumTypes.fromLegacy(element.pullInteger("datum")); type = VerticalDatumTypes.guess(name, null, null);
/** * Guesses the type of a datum of the given name. This method attempts to guess only if the given name * contains at least one letter. If the type can not be determined, returns {@code null}. * * @param name name of the datum for which to guess a type, or {@code null}. * @return a datum type, or {@code null} if none can be guessed. */ private static VerticalDatumType guess(final String name) { if (name != null) { if (CharSequences.equalsFiltered("Mean Sea Level", name, Characters.Filter.LETTERS_AND_DIGITS, true)) { return VerticalDatumType.GEOIDAL; } for (int i=0; i<name.length();) { final int c = name.codePointAt(i); if (Character.isLetter(c)) { return CodeList.valueOf(VerticalDatumType.class, new VerticalDatumTypes(name)); } i += Character.charCount(c); } } return null; }
VerticalDatumType type = null; if (isWKT1) { type = VerticalDatumTypes.fromLegacy(element.pullInteger("datum")); type = VerticalDatumTypes.guess(name, null, null);
/** * Guesses the type of a datum of the given name. This method attempts to guess only if the given name * contains at least one letter. If the type can not be determined, returns {@code null}. * * @param name name of the datum for which to guess a type, or {@code null}. * @return a datum type, or {@code null} if none can be guessed. */ private static VerticalDatumType guess(final String name) { if (name != null) { if (CharSequences.equalsFiltered("Mean Sea Level", name, Characters.Filter.LETTERS_AND_DIGITS, true)) { return VerticalDatumType.GEOIDAL; } for (int i=0; i<name.length();) { final int c = name.codePointAt(i); if (Character.isLetter(c)) { return CodeList.valueOf(VerticalDatumType.class, new VerticalDatumTypes(name)); } i += Character.charCount(c); } } return null; }
/** * Returns the type of this datum, or infers the type from the datum name if no type were specified. * The later case occurs after unmarshalling, since GML 3.2 does not contain any attribute for the datum type. * It may also happen if the datum were created using reflection. * * <p>This method uses heuristic rules and may be changed in any future SIS version. If the type can not be * determined, default on the ellipsoidal type since it will usually implies no additional calculation.</p> * * <p>No synchronization needed; this is not a problem if this value is computed twice. * This method returns only existing immutable instances.</p> * * @see #getVerticalDatumType() * @see #getTypeElement() */ private VerticalDatumType type() { VerticalDatumType t = type; if (t == null) { final ReferenceIdentifier name = super.getName(); type = t = VerticalDatumTypes.guess(name != null ? name.getCode() : null, super.getAlias(), null); } return t; }
/** * Formats this datum as a <cite>Well Known Text</cite> {@code VerticalDatum[…]} element. * * <div class="note"><b>Compatibility note:</b> * OGC 01-009 defined numerical codes for various vertical datum types, for example 2005 for geoidal height * and 2002 for ellipsoidal height. Such codes were formatted for all {@code Datum} subtypes in WKT 1. * Datum types became provided only for vertical datum in the ISO 19111:2003 specification, then removed * completely in ISO 19111:2007.</div> * * @return {@code "VerticalDatum"} (WKT 2) or {@code "Vert_Datum"} (WKT 1). * * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#71">WKT 2 specification §10.2</a> */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); if (formatter.getConvention().majorVersion() == 1) { formatter.append(VerticalDatumTypes.toLegacy(type())); return WKTKeywords.Vert_Datum; } return formatter.shortOrLong(WKTKeywords.VDatum, WKTKeywords.VerticalDatum); }
/** * Formats this datum as a <cite>Well Known Text</cite> {@code VerticalDatum[…]} element. * * <div class="note"><b>Compatibility note:</b> * OGC 01-009 defined numerical codes for various vertical datum types, for example 2005 for geoidal height * and 2002 for ellipsoidal height. Such codes were formatted for all {@code Datum} subtypes in WKT 1. * Datum types became provided only for vertical datum in the ISO 19111:2003 specification, then removed * completely in ISO 19111:2007.</div> * * @return {@code "VerticalDatum"} (WKT 2) or {@code "Vert_Datum"} (WKT 1). * * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#71">WKT 2 specification §10.2</a> */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); if (formatter.getConvention().majorVersion() == 1) { formatter.append(VerticalDatumTypes.toLegacy(type())); return WKTKeywords.Vert_Datum; } return formatter.shortOrLong(WKTKeywords.VDatum, WKTKeywords.VerticalDatum); }
final VerticalDatumType type = VerticalDatumTypes.guess(datum.getName().getCode(), datum.getAlias(), cs.getAxis(0)); if (!VerticalDatumType.OTHER_SURFACE.equals(type)) { datum = datumFactory.createVerticalDatum(referencing.getProperties(datum, true), type);
final VerticalDatumType type = VerticalDatumTypes.guess(datum.getName().getCode(), datum.getAlias(), cs.getAxis(0)); if (!VerticalDatumType.OTHER_SURFACE.equals(type)) { datum = datumFactory.createVerticalDatum(referencing.getProperties(datum, true), type);