throw new GazetteerException(Resources.format(Resources.Keys.IllegalLatitudeBand_1, Encoder.latitudeBand(φs))); λ0 = ZONER.centralMeridian(zone); crs = owner.projection(Math.signum(φs), λ0); final int info = ROW_RESOLVER[latitudeBand]; // Contains the above-cited northing value. int zoneError = ZONER.zone(φ, λ) - zone; if (zoneError != 0) { final int zc = ZONER.zoneCount(); if (zoneError < zc/-2) zoneError += zc; // If change of zone crosses the anti-meridian. if (zoneError > zc/+2) zoneError -= zc; if (ZONER.isSpecialCase(zone, φ)) { isValid = Math.abs(zoneError) <= 2; // Tolerance in zone numbers for high latitudes. } else { if (zone != 0) { double width = ZONER.width; if (!ZONER.isSpecialCase(zone, φs)) width /= 2; // Be strict only if not Norway or Svalbard. changed = clipGeographicBoundingBox(λ0 - width, φs, λ0 + width, upperBound(φs));
/** * Creates a Universal Transverse Mercator (UTM) or a Universal Polar Stereographic (UPS) projected CRS * using the Apache SIS factory implementation. This method restricts the factory to SIS implementation * instead than arbitrary factory in order to met the contract saying that {@link CommonCRS} methods * should never fail. * * @param code the EPSG code, or 0 if none. * @param baseCRS the geographic CRS on which the projected CRS is based. * @param isUTM {@code true} for UTM or {@code false} for UPS. Note: redundant with the given latitude. * @param latitude a latitude in the zone of the desired projection, to be snapped to 0°, 90°S or 90°N. * @param longitude a longitude in the zone of the desired projection, to be snapped to UTM central meridian. * @param derivedCS the projected coordinate system. */ static ProjectedCRS createUniversal(final int code, final GeographicCRS baseCRS, final boolean isUTM, final double latitude, final double longitude, final CartesianCS derivedCS) { final OperationMethod method; try { method = DefaultFactories.forBuildin(MathTransformFactory.class, DefaultMathTransformFactory.class) .getOperationMethod(isUTM ? TransverseMercator.NAME : PolarStereographicA.NAME); } catch (NoSuchIdentifierException e) { throw new IllegalStateException(e); // Should not happen with SIS implementation. } final ParameterValueGroup parameters = method.getParameters().createValue(); String name = isUTM ? TransverseMercator.Zoner.UTM.setParameters(parameters, latitude, longitude) : PolarStereographicA.setParameters(parameters, latitude >= 0); final DefaultConversion conversion = new DefaultConversion(properties(0, name, null, false), method, null, parameters); name = baseCRS.getName().getCode() + " / " + name; return new DefaultProjectedCRS(properties(code, name, null, false), baseCRS, conversion, derivedCS); }
/** * Verifies that {@link TransverseMercator.Zoner#isNorway(double)} and * {@link TransverseMercator.Zoner#isSvalbard(double)} are consistent with the latitude bands. */ @Test @DependsOnMethod("testLatitudeBand") public void verifyZonerConsistency() { for (double φ = TransverseMercator.Zoner.SOUTH_BOUNDS; φ < TransverseMercator.Zoner.NORTH_BOUNDS; φ++) { final String latitude = String.valueOf(φ); final char band = MilitaryGridReferenceSystem.Encoder.latitudeBand(φ); assertTrue (latitude, band >= 'C' && band <= 'X'); assertEquals(latitude, band == 'V', TransverseMercator.Zoner.isNorway(φ)); assertEquals(latitude, band == 'X', TransverseMercator.Zoner.isSvalbard(φ)); } }
final boolean isUTM = latitude >= TransverseMercator.Zoner.SOUTH_BOUNDS && latitude < TransverseMercator.Zoner.NORTH_BOUNDS; final int zone = isUTM ? TransverseMercator.Zoner.UTM.zone(latitude, longitude) : POLAR; final Integer key = isSouth ? -zone : zone; ProjectedCRS crs;
final boolean isUTM = latitude >= TransverseMercator.Zoner.SOUTH_BOUNDS && latitude < TransverseMercator.Zoner.NORTH_BOUNDS; final int zone = isUTM ? TransverseMercator.Zoner.UTM.zone(latitude, longitude) : POLAR; final Integer key = isSouth ? -zone : zone; ProjectedCRS crs;
φmax = TransverseMercator.Zoner.NORTH_BOUNDS; final double λ0 = ZONER.centralMeridian(zone); λmin = λ0 - ZONER.width / 2; λmax = λ0 + ZONER.width / 2; if ((t = geographicArea.getMinimum(0)) >= λmin) λmin = t; else clip = true; if ((t = geographicArea.getMaximum(0)) <= λmax) λmax = t; else clip = true; boolean isSpecialCase = ZONER.isSpecialCase(φmin, φmax, λmin, λmax); if (clip) {
metadata.addReferenceSystem(datum.universal(1, TransverseMercator.Zoner.UTM.centralMeridian(utmZone)));
int zoneStart = 0; // Zero-based (i.e. standard zone number minus 1). int zoneEnd = 0; // Exclusive. final int zoneCount = ZONER.zoneCount(); if (φmax >= TransverseMercator.Zoner.SOUTH_BOUNDS && φmin < TransverseMercator.Zoner.NORTH_BOUNDS) { southUTM = (φmin < 0); zoneStart = ZONER.zone(0, geographicArea.getLowerCorner().getOrdinate(0)) - 1; // Inclusive. zoneEnd = ZONER.zone(0, geographicArea.getUpperCorner().getOrdinate(0)); // Exclusive. if (zoneEnd < zoneStart) { upper = 0; do { final double λ = ZONER.centralMeridian((zone % zoneCount) + 1); final double φ; if (southPole) {
final boolean isUTM = φ >= TransverseMercator.Zoner.SOUTH_BOUNDS && φ < TransverseMercator.Zoner.NORTH_BOUNDS; final int zone = isUTM ? ZONER.zone(φ, λ) : POLE; final int signedZone = MathFunctions.isNegative(φ) ? -zone : zone; if (signedZone == 0) {
case 42002: isUTM = (latitude == 0) && (Zoner.UTM.centralMeridian(Zoner.UTM.zone(0, longitude)) == longitude); break; case 42003: method = "Orthographic"; param = Constants.LATITUDE_OF_ORIGIN; break; case 42004: method = "Equirectangular"; param = Constants.STANDARD_PARALLEL_1; break;
metadata.addReferenceSystem(datum.universal(1, TransverseMercator.Zoner.UTM.centralMeridian(utmZone)));
case 42002: isUTM = (latitude == 0) && (Zoner.UTM.centralMeridian(Zoner.UTM.zone(0, longitude)) == longitude); break; case 42003: method = "Orthographic"; param = Constants.LATITUDE_OF_ORIGIN; break; case 42004: method = "Equirectangular"; param = Constants.STANDARD_PARALLEL_1; break;
final OperationMethod method = projection.getMethod(); if (IdentifiedObjects.isHeuristicMatchForName(method, TransverseMercator.NAME)) { crsZone = ZONER.zone(projection.getParameterValues()); } else if (IdentifiedObjects.isHeuristicMatchForName(method, PolarStereographicA.NAME)) { crsZone = POLE * PolarStereographicA.isUPS(projection.getParameterValues());
continue; return crs.universal(latitude, TransverseMercator.Zoner.UTM.centralMeridian(zone));
continue; return crs.universal(latitude, TransverseMercator.Zoner.UTM.centralMeridian(zone));
ArgumentChecks.ensureBetween("longitude", -Formulas.LONGITUDE_MAX, Formulas.LONGITUDE_MAX, longitude); setConversionMethod(TransverseMercator.NAME); setConversionName(zoner.setParameters(parameters, latitude, longitude)); return this;
ArgumentChecks.ensureBetween("longitude", -Formulas.LONGITUDE_MAX, Formulas.LONGITUDE_MAX, longitude); setConversionMethod(TransverseMercator.NAME); setConversionName(zoner.setParameters(parameters, latitude, longitude)); return this;
int zone = zone(latitude, longitude); String name; if (this == ANY) { name = "UTM"; if (latitude != 0 || longitude != centralMeridian(zone)) { name = NAME; zone = 0; name = name(); latitude = 0; longitude = centralMeridian(zone);
int zone = zone(latitude, longitude); String name; if (this == ANY) { name = "UTM"; if (latitude != 0 || longitude != centralMeridian(zone)) { name = NAME; zone = 0; name = name(); latitude = 0; longitude = centralMeridian(zone);
/** * Creates a Universal Transverse Mercator (UTM) or a Universal Polar Stereographic (UPS) projected CRS * using the Apache SIS factory implementation. This method restricts the factory to SIS implementation * instead than arbitrary factory in order to meet the contract saying that {@link CommonCRS} methods * should never fail. * * @param code the EPSG code, or 0 if none. * @param baseCRS the geographic CRS on which the projected CRS is based. * @param isUTM {@code true} for UTM or {@code false} for UPS. Note: redundant with the given latitude. * @param latitude a latitude in the zone of the desired projection, to be snapped to 0°, 90°S or 90°N. * @param longitude a longitude in the zone of the desired projection, to be snapped to UTM central meridian. * @param derivedCS the projected coordinate system. */ static ProjectedCRS createUniversal(final int code, final GeographicCRS baseCRS, final boolean isUTM, final double latitude, final double longitude, final CartesianCS derivedCS) { final OperationMethod method; try { method = DefaultFactories.forBuildin(MathTransformFactory.class, DefaultMathTransformFactory.class) .getOperationMethod(isUTM ? TransverseMercator.NAME : PolarStereographicA.NAME); } catch (NoSuchIdentifierException e) { throw new IllegalStateException(e); // Should not happen with SIS implementation. } final ParameterValueGroup parameters = method.getParameters().createValue(); String name = isUTM ? TransverseMercator.Zoner.UTM.setParameters(parameters, latitude, longitude) : PolarStereographicA.setParameters(parameters, latitude >= 0); final DefaultConversion conversion = new DefaultConversion(properties(0, name, null, false), method, null, parameters); name = baseCRS.getName().getCode() + " / " + name; return new DefaultProjectedCRS(properties(code, name, null, false), baseCRS, conversion, derivedCS); }