/** * Creates an automatic-zone UTM map projection. * * @return an automatic-zone UTM map projection */ public static UTMProjection createAutoZoneProjection() { return createProjection(AUTO_PROJECTION_NAME, 0, false); }
/** * Gets the UTM projection suitable for the given geodetic coordinate. * * @param geoPos a geodetic coordinate * * @return a suitable UTM projection */ public static MapProjection getSuitableProjection(final GeoPos geoPos) { int zoneIndex = getZoneIndex(geoPos.getLon()); final boolean south = geoPos.getLat() < 0.0; final String projName = getProjectionName(zoneIndex, south); MapProjection projection = MapProjectionRegistry.getProjection(projName); return projection; }
/** * Registers all possible UTM projections in the <code>{@link MapProjectionRegistry}</code>. The projection names * have the form "UTM Zone 1" to "UTM Zone 64" for the northern hemisphere and "UTM Zone 1, South" to "UTM Zone 64, * South" for the southern. Also contained is the special auto-UTM projection with the name <code>{@link * #AUTO_PROJECTION_NAME}</code>. */ public static void registerProjections() { if (!_projectionsRegistered) { MapProjectionRegistry.registerProjection(createAutoZoneProjection()); registerProjections(false); registerProjections(true); } _projectionsRegistered = true; }
/** * Creates an UTM map projection for the specified parameters. * * @param zoneIndex the zone index in the range 0 to {@link #MAX_UTM_ZONE} - 1. * @param south whether or not the projection is defined for the southern hemispere * * @return an UTM map projection * * @see #getProjectionName */ public static UTMProjection createProjection(int zoneIndex, boolean south) { return createProjection(getProjectionName(zoneIndex, south), zoneIndex, south); }
public void testGetZoneIndexAndCentralMeridian() { assertEquals(0, UTM.getZoneIndex(-190f)); assertEquals(0, UTM.getZoneIndex(-180f)); assertEquals(1, UTM.getZoneIndex(-172f)); assertEquals(15, UTM.getZoneIndex(-90f)); assertEquals(23, UTM.getZoneIndex(-40f)); assertEquals(30, UTM.getZoneIndex(0f)); assertEquals(36, UTM.getZoneIndex(+40f)); assertEquals(45, UTM.getZoneIndex(+90f)); assertEquals(58, UTM.getZoneIndex(+172f)); assertEquals(59, UTM.getZoneIndex(+180f)); assertEquals(59, UTM.getZoneIndex(+190f)); assertEquals(-177.0, UTM.getCentralMeridian(-1), 1e-10); assertEquals(-177.0, UTM.getCentralMeridian(0), 1e-10); assertEquals(-87.0, UTM.getCentralMeridian(15), 1e-10); assertEquals(-39.0, UTM.getCentralMeridian(23), 1e-10); assertEquals(3.0, UTM.getCentralMeridian(30), 1e-10); assertEquals(39.0, UTM.getCentralMeridian(36), 1e-10); assertEquals(93.0, UTM.getCentralMeridian(45), 1e-10); assertEquals(171.0, UTM.getCentralMeridian(58), 1e-10); assertEquals(177.0, UTM.getCentralMeridian(59), 1e-10); assertEquals(177.0, UTM.getCentralMeridian(60), 1e-10); } }
/** * Creates a new UTM projection instance. * * @param name the projection name, e.g. "UTM Zone 32" * @param zoneIndex the zne as zero-based index, e.g. 31 for zone 32 * @param south false, if the zone is on the northern hemisphere * * @return the new projection */ public static UTMProjection create(final String name, int zoneIndex, boolean south) { final double[] params = UTM.getProjectionParams(zoneIndex, south); final MapTransform mapTransform = MapTransformFactory.createTransform("Transverse_Mercator", params); final UTMProjection mapProjection = new UTMProjection(name, mapTransform, zoneIndex, south); return mapProjection; }
/** * Gets the UTM projection parameters for the transverse mercator transformation. * * @param zoneIndex the zone index in the range 0 to {@link #MAX_UTM_ZONE} - 1. * @param south whether or not the projection is defined for the southern hemispere * * @return the UTM projection parameters */ public static double[] getProjectionParams(int zoneIndex, boolean south) { return new double[]{Ellipsoid.WGS_84.getSemiMajor(), // semi_major Ellipsoid.WGS_84.getSemiMinor(), // semi_minor 0.0, // latitude_of_origin (not used) getCentralMeridian(zoneIndex), // central_meridian 0.9996, // scale_factor 500000.0, // false_easting south ? 10000000.0 : 0.0 // false_northing }; }
/** * Creates a new UTM projection instance. * * @param zoneIndex the zne as zero-based index, e.g. 31 for zone 32 * @param south false, if the zone is on the northern hemisphere * * @return the new projection */ public static UTMProjection create(int zoneIndex, boolean south) { return create(UTM.getProjectionName(zoneIndex, south), zoneIndex, south); }
/** * This method is called within the <code>{@link org.esa.beam.framework.dataop.maptransf.MapProjectionRegistry#registerDescriptor}</code> * method after an instance of this <code>MapTransformDescriptor</code> has been successfully registered. * <p/> * The method delegates the call to <code>{@link org.esa.beam.framework.dataop.maptransf.UTM#registerProjections}</code> * in order to register all frequently used UTM projections. */ @Override public void registerProjections() { UTM.registerProjections(); MapProjectionRegistry.registerProjection(new MapProjection(getName(), createTransform(null), false)); }
public void testGetProjectionParams() { double[] p; p = UTM.getProjectionParams(0, false); assertEquals(6378137.0, p[0], 1e-10); assertEquals(6356752.3, p[1], 1e-10); assertEquals(0.0, p[6], 1e-10); p = UTM.getProjectionParams(32, false); assertEquals(6378137.0, p[0], 1e-10); assertEquals(6356752.3, p[1], 1e-10); assertEquals(0.0, p[6], 1e-10); p = UTM.getProjectionParams(59, true); assertEquals(6378137.0, p[0], 1e-10); assertEquals(6356752.3, p[1], 1e-10); assertEquals(10000000.0, p[6], 1e-10); p = UTM.getProjectionParams(-1, false); assertEquals(-177.0, p[3], 1e-10); p = UTM.getProjectionParams(60, false); assertEquals(+177.0, p[3], 1e-10);
private static void registerProjections(boolean south) { for (int zoneIndex = 0; zoneIndex < MAX_UTM_ZONE; zoneIndex++) { MapProjection mapProjection = createProjection(zoneIndex, south); MapProjectionRegistry.registerProjection(mapProjection); } }
/** * Creates the UTM MapGeocoding */ private void setMapGeoCoding() { final LandsatHeader landsatHeader = landsatTM.getHeader(); final GeometricData geoData = landsatHeader.getGeoData(); final float pixelSize = landsatHeader.getPixelSize(); GeoPoint projCenter = geoData.getGeoPointAt(LandsatConstants.Points.CENTER); float pcX = projCenter.getPixelX(); float pcY = projCenter.getPixelY(); final MapProjection mappro = UTM.createProjection(geoData.getMapZoneNumber() - 1, !projCenter.isNorthernHemisphere()); final int width = landsatHeader.getImageWidth(); final int height = landsatHeader.getImageHeight(); MapInfo map = new MapInfo(mappro, pcX, pcY, (float) projCenter.getEasting(), (float) projCenter.getNorthing(), pixelSize, pixelSize, Datum.WGS_84); map.setSceneWidth(width); map.setSceneHeight(height); map.setOrientation(geoData.getLookAngle() * -1); final MapGeoCoding mapGeocoding = new MapGeoCoding(map); product.setGeoCoding(mapGeocoding); }
@Test public void testDecodeQualificationForTIFFWithGeoInformation() throws IOException { final Product product = new Product("p", "t", 20, 10); final Band band = product.addBand("band1", ProductData.TYPE_INT8); band.ensureRasterData(); final MapInfo mapInfo = new MapInfo(UTM.createProjection(26, true), 0, 0, 0, 0, 1, 1, Datum.WGS_84); mapInfo.setSceneWidth(product.getSceneRasterWidth()); mapInfo.setSceneHeight(product.getSceneRasterHeight()); product.setGeoCoding(new MapGeoCoding(mapInfo)); final ImageInputStream inputStream = writeToInputStream(product); final DecodeQualification decodeQualification = GeoTiffProductReaderPlugIn.getDecodeQualificationImpl(inputStream); assertEquals(DecodeQualification.SUITABLE, decodeQualification); }
final float orientationAngle = (float) leaderFile.getUTMOrientationAngle(); final MapInfo mapInfo = new MapInfo(UTM.createProjection(zoneIndex - 1, isSouth), sceneWidth * 0.5f, sceneHeight * 0.5f, (float) easting, (float) northing,
final float orientationAngle = (float) leaderFile.getUTMOrientationAngle(); final MapInfo mapInfo = new MapInfo(UTM.createProjection(zoneIndex - 1, isSouth), sceneWidth * 0.5f, sceneHeight * 0.5f, (float) easting, (float) northing,