當前位置: 首頁>>代碼示例>>Java>>正文


Java CRS.equalsIgnoreMetadata方法代碼示例

本文整理匯總了Java中org.geotools.referencing.CRS.equalsIgnoreMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java CRS.equalsIgnoreMetadata方法的具體用法?Java CRS.equalsIgnoreMetadata怎麽用?Java CRS.equalsIgnoreMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.geotools.referencing.CRS的用法示例。


在下文中一共展示了CRS.equalsIgnoreMetadata方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: actionPerformed

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    ProductSceneView view = SnapApp.getDefault().getSelectedProductSceneView();
    final GeoCoding geoCoding = view.getProduct().getSceneGeoCoding();
    boolean isGeographic = false;
    if (geoCoding instanceof MapGeoCoding) {
        MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding;
        MapTransformDescriptor transformDescriptor = mapGeoCoding.getMapInfo()
                .getMapProjection().getMapTransform().getDescriptor();
        String typeID = transformDescriptor.getTypeID();
        if (typeID.equals(IdentityTransformDescriptor.TYPE_ID)) {
            isGeographic = true;
        }
    } else if (geoCoding instanceof CrsGeoCoding) {
        isGeographic = CRS.equalsIgnoreMetadata(geoCoding.getMapCRS(), DefaultGeographicCRS.WGS84);
    }

    if (isGeographic) {
        exportImage(view);
    } else {
        String message = "Product must be in ''Geographic Lat/Lon'' projection.";
        Dialogs.showInformation(message, null);
    }
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:25,代碼來源:ExportKmzFileAction.java

示例2: getMatchingCRSCode

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked"})
private String getMatchingCRSCode(Layer layer) {
    Set<String> srsSet = layer.getSrs();
    String modelSRS = CRS.toSRS(modelCRS);
    if (modelSRS != null) {
        for (String srs : srsSet) {
            try {
                final CoordinateReferenceSystem crs = CRS.decode(srs,true);
                if (CRS.equalsIgnoreMetadata(crs, modelCRS)) {
                    return srs;
                }
            } catch (FactoryException ignore) {
            }
        }
    }
    return null;
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:18,代碼來源:WmsAssistantPage2.java

示例3: reprojectBounds

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
public static Bounds reprojectBounds(Bounds inBounds, String fromCRS, String toCRS) {
	if (fromCRS.equals(toCRS))
		return inBounds;

	try {
		double ulx = inBounds.getLeft();
		double uly = inBounds.getTop();
		double lrx = inBounds.getRight();
		double lry = inBounds.getBottom();

		CoordinateReferenceSystem sourceCRS = CRS.decode(fromCRS);
		CoordinateReferenceSystem targetCRS = CRS.decode(toCRS);
		if (CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
			return inBounds;
		} else {
			ReferencedEnvelope re = new ReferencedEnvelope(ulx, lrx, lry, uly, sourceCRS);
			BoundingBox b = re.toBounds(targetCRS);
			return getBounds(b);
		}
	} catch (Exception e) {
	}

	return null;
}
 
開發者ID:lizardtechblog,項目名稱:ExpressZip,代碼行數:25,代碼來源:MapModel.java

示例4: setCRS

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * Set the coordinate reference system that pertains to the feature data
 * that will be queried by this helper.
 *
 * @param crs data coordinate reference system
 */
protected void setCRS( CoordinateReferenceSystem crs ) {
    this.dataCRS = crs;

    MapContent content = getMapContent();
    if (content == null) {
        throw new IllegalStateException("map context should not be null");
    }

    final CoordinateReferenceSystem contextCRS = content.getCoordinateReferenceSystem();
    transformRequired = false;
    if (contextCRS != null && crs != null && !CRS.equalsIgnoreMetadata(contextCRS, dataCRS)) {
        transformRequired = true;
    }
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:21,代碼來源:InfoToolHelper.java

示例5: actionPerformed

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    view = SnapApp.getDefault().getSelectedProductSceneView();
    final GeoCoding geoCoding = view.getProduct().getGeoCoding();
    boolean isGeographic = false;
    if (geoCoding instanceof MapGeoCoding) {
        MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding;
        MapTransformDescriptor transformDescriptor = mapGeoCoding.getMapInfo()
                .getMapProjection().getMapTransform().getDescriptor();
        String typeID = transformDescriptor.getTypeID();
        if (typeID.equals(IdentityTransformDescriptor.TYPE_ID)) {
            isGeographic = true;
        }
    } else if (geoCoding instanceof CrsGeoCoding) {
        isGeographic = CRS.equalsIgnoreMetadata(geoCoding.getMapCRS(), DefaultGeographicCRS.WGS84);
    }

    if (isGeographic) {
        final File output = fetchOutputFile(view);
        if (output == null) {
            return;
        }
        final String title = "KMZ Export";
        final ProgressMonitorSwingWorker worker = new KmzSwingWorker(title, output);
        worker.executeWithBlocking();
    } else {
        String message = "Product must be in ''Geographic Lat/Lon'' projection.";
        SnapDialogs.showInformation(message, null);
    }
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:31,代碼來源:ExportTimeBasedKmz.java

示例6: isGeographicLatLon

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
private boolean isGeographicLatLon(GeoCoding geoCoding) {
    if (geoCoding instanceof MapGeoCoding) {
        MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding;
        MapTransformDescriptor transformDescriptor = mapGeoCoding.getMapInfo()
                .getMapProjection().getMapTransform().getDescriptor();
        String typeID = transformDescriptor.getTypeID();
        if (typeID.equals(IdentityTransformDescriptor.TYPE_ID)) {
            return true;
        }
    } else if (geoCoding instanceof CrsGeoCoding) {
        return CRS.equalsIgnoreMetadata(geoCoding.getMapCRS(), DefaultGeographicCRS.WGS84);
    }
    return false;
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:15,代碼來源:OverlayWorldMapLayerAction.java

示例7: collectCompatibleRasterDataNodes

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
private void collectCompatibleRasterDataNodes(CoordinateReferenceSystem thisCrs,
                                              RasterDataNode[] bands, Collection<RasterDataNode> rasterDataNodes) {
    for (RasterDataNode node : bands) {
        CoordinateReferenceSystem otherCrs = Product.findModelCRS(node.getGeoCoding());
        // For GeoTools, two CRS where unequal if the authorities of their CS only differ in version
        // This happened with the S-2 L1C CRS, namely an EPSG:32615. Here one authority's version was null,
        // the other "7.9". Extremely annoying to debug and find out :-(   (nf, Feb 2013)
        if (CRS.equalsIgnoreMetadata(thisCrs, otherCrs)
                || haveCommonReferenceIdentifiers(thisCrs, otherCrs)) {
            rasterDataNodes.add(node);
        }
    }
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:14,代碼來源:ProductLayerAssistantPage.java

示例8: testWriteReadTiePointGeoCoding

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
@Test
public void testWriteReadTiePointGeoCoding() throws IOException {
    setTiePointGeoCoding(outProduct);
    final Band bandUInt8 = outProduct.addBand("band_2", ProductData.TYPE_UINT16);
    bandUInt8.setDataElems(createShortData(getProductSize(), 23));
    final Product inProduct = writeReadProduct();
    try {
        assertEquals(outProduct.getName(), inProduct.getName());
        assertEquals(outProduct.getProductType(), inProduct.getProductType());
        assertEquals(outProduct.getNumBands(), inProduct.getNumBands());
        assertEquals(outProduct.getBandAt(0).getName(), inProduct.getBandAt(0).getName());
        assertEquals(outProduct.getBandAt(0).getDataType(), inProduct.getBandAt(0).getDataType());
        assertEquals(outProduct.getBandAt(0).getScalingFactor(), inProduct.getBandAt(0).getScalingFactor(), 1.0e-6);
        assertEquals(outProduct.getBandAt(0).getScalingOffset(), inProduct.getBandAt(0).getScalingOffset(), 1.0e-6);
        assertEquals(location, inProduct.getFileLocation());
        assertNotNull(inProduct.getSceneGeoCoding());
        assertNotNull(outProduct.getSceneGeoCoding());
        assertEquals(inProduct.getSceneGeoCoding().canGetGeoPos(), outProduct.getSceneGeoCoding().canGetGeoPos());
        assertEquals(inProduct.getSceneGeoCoding().isCrossingMeridianAt180(), outProduct.getSceneGeoCoding().isCrossingMeridianAt180());

        if (inProduct.getSceneGeoCoding() instanceof CrsGeoCoding) {
            assertEquals(CrsGeoCoding.class, outProduct.getSceneGeoCoding().getClass());
            CRS.equalsIgnoreMetadata(inProduct.getSceneGeoCoding(), outProduct.getSceneGeoCoding());
        } else if (inProduct.getSceneGeoCoding() instanceof TiePointGeoCoding) {
            assertEquals(TiePointGeoCoding.class, outProduct.getSceneGeoCoding().getClass());
        }
        final int width = outProduct.getSceneRasterWidth();
        final int height = outProduct.getSceneRasterHeight();
        GeoPos geoPos1 = null;
        GeoPos geoPos2 = null;
        final String msgPattern = "%s at [%d,%d] is not equal:";
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                final PixelPos pixelPos = new PixelPos(i, j);
                geoPos1 = inProduct.getSceneGeoCoding().getGeoPos(pixelPos, geoPos1);
                geoPos2 = outProduct.getSceneGeoCoding().getGeoPos(pixelPos, geoPos2);
                assertEquals(String.format(msgPattern, "Latitude", i, j), geoPos1.lat, geoPos2.lat, 1e-6f);
                assertEquals(String.format(msgPattern, "Longitude", i, j), geoPos1.lon, geoPos2.lon, 1e-6f);
            }
        }
    } finally {
        inProduct.dispose();
    }
}
 
開發者ID:senbox-org,項目名稱:s2tbx,代碼行數:45,代碼來源:JP2ProductWriteReadTest.java

示例9: transformRequestEnvelope

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * transforms (if necessary) the requested envelope into the CRS used by
 * this reader.
 *
 * @throws DataSourceException
 */
public static void transformRequestEnvelope(
		final GeoWaveRasterReaderState state,
		final CoordinateReferenceSystem crs )
		throws DataSourceException {

	if (CRS.equalsIgnoreMetadata(
			state.getRequestedEnvelope().getCoordinateReferenceSystem(),
			crs)) {
		state.setRequestEnvelopeXformed(state.getRequestedEnvelope());

		return; // and finish
	}

	try {
		/** Buffered factory for coordinate operations. */

		// transforming the envelope back to the dataset crs in
		final MathTransform transform = OPERATION_FACTORY.createOperation(
				state.getRequestedEnvelope().getCoordinateReferenceSystem(),
				crs).getMathTransform();

		if (transform.isIdentity()) { // Identity Transform ?
			state.setRequestEnvelopeXformed(state.getRequestedEnvelope());
			return; // and finish
		}

		state.setRequestEnvelopeXformed(CRS.transform(
				transform,
				state.getRequestedEnvelope()));
		state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
				crs);

		// if (config.getIgnoreAxisOrder() == false) { // check for axis
		// order
		// required
		final int indexX = indexOfX(crs);
		final int indexY = indexOfY(crs);
		final int indexRequestedX = indexOfX(state.getRequestedEnvelope().getCoordinateReferenceSystem());
		final int indexRequestedY = indexOfY(state.getRequestedEnvelope().getCoordinateReferenceSystem());

		// x Axis problem ???
		if ((indexX == indexRequestedY) && (indexY == indexRequestedX)) {
			state.setAxisSwap(true);
			final Rectangle2D tmp = new Rectangle2D.Double(
					state.getRequestEnvelopeXformed().getMinimum(
							1),
					state.getRequestEnvelopeXformed().getMinimum(
							0),
					state.getRequestEnvelopeXformed().getSpan(
							1),
					state.getRequestEnvelopeXformed().getSpan(
							0));
			state.setRequestEnvelopeXformed(new GeneralEnvelope(
					tmp));
			state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
					crs);
		}
		else if ((indexX == indexRequestedX) && (indexY == indexRequestedY)) {
			// everything is fine
		}
		else {
			throw new DataSourceException(
					"Unable to resolve the X Axis problem");
		}
		// }
	}
	catch (final Exception e) {
		throw new DataSourceException(
				"Unable to create a coverage for this source",
				e);
	}
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:79,代碼來源:GeoWaveRasterReader.java

示例10: clipImageToFeatureSource

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
private Coverage clipImageToFeatureSource(RenderedImage image, ReferencedEnvelope bounds,
		FeatureSource<SimpleFeatureType, SimpleFeature> featureSource) throws IOException, FactoryException,
		MismatchedDimensionException, TransformException {
	FeatureCollection<SimpleFeatureType, SimpleFeature> collection = featureSource.getFeatures();

	CoordinateReferenceSystem crsFeatures = featureSource.getSchema().getCoordinateReferenceSystem();
	CoordinateReferenceSystem crsMap = bounds.getCoordinateReferenceSystem();
	boolean needsReproject = !CRS.equalsIgnoreMetadata(crsFeatures, crsMap);
	MathTransform transform = CRS.findMathTransform(crsFeatures, crsMap, true);

	FeatureIterator<SimpleFeature> iterator = collection.features();
	List<Geometry> all = new ArrayList<Geometry>();
	try {
		while (iterator.hasNext()) {
			SimpleFeature feature = iterator.next();
			Geometry geometry = (Geometry) feature.getDefaultGeometry();
			if (geometry == null)
				continue;
			if (!geometry.isSimple())
				continue;
			if (needsReproject) {
				geometry = JTS.transform(geometry, transform);
				System.out.println("Reprojected a geometry.  Result is " + geometry.toString());
			}
			Geometry intersection = geometry.intersection(JTS.toGeometry(bounds));
			if (intersection.isEmpty()) {
				continue;
			}
			// String name = (String) feature.getAttribute("NAME");
			// if (name == null)
			// name = (String) feature.getAttribute("CNTRY_NAME");
			if (intersection instanceof MultiPolygon) {
				MultiPolygon mp = (MultiPolygon) intersection;
				for (int i = 0; i < mp.getNumGeometries(); i++) {
					com.vividsolutions.jts.geom.Polygon g = (com.vividsolutions.jts.geom.Polygon) mp.getGeometryN(i);
					Geometry gIntersection = IntersectUtils.intersection(g, JTS.toGeometry(bounds));
					if (gIntersection.isEmpty()) {
						continue;
					}
					all.add(g);
				}
			} else if (intersection instanceof Polygon)
				all.add(intersection);
			else
				continue;
		}
	} finally {
		if (iterator != null) {
			iterator.close();
		}
	}
	GridCoverageFactory gridCoverageFactory = new GridCoverageFactory();
	Coverage coverage = gridCoverageFactory.create("Raster", image, bounds);
	Coverage clippedCoverage = null;
	if (all.size() > 0) {
		CoverageProcessor processor = new CoverageProcessor();
		ParameterValueGroup params = processor.getOperation("CoverageCrop").getParameters();
		params.parameter("Source").setValue(coverage);
		GeometryFactory factory = JTSFactoryFinder.getGeometryFactory(null);
		Geometry[] a = all.toArray(new Geometry[0]);
		GeometryCollection c = new GeometryCollection(a, factory);
		// params.parameter("ENVELOPE").setValue(bounds);
		params.parameter("ROI").setValue(c);
		params.parameter("ForceMosaic").setValue(true);
		clippedCoverage = processor.doOperation(params);
	}
	if (all.size() == 0) {
		logger.info("Crop by shapefile requested but no simple features matched extent!");
	}
	return clippedCoverage;
}
 
開發者ID:lizardtechblog,項目名稱:ExpressZip,代碼行數:72,代碼來源:Job.java

示例11: getWktString

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
private String getWktString(String projection) throws NoSuchAuthorityCodeException, FactoryException,
		MismatchedDimensionException, TransformException, IOException {
	String retval = null;

	// On construction, we set up with the native CRS of the underlying
	// shapefile. If that's what they asked for, send it back.
	if ((wkt != null)
			&& (projection != null && CRS.equalsIgnoreMetadata(nativeBounds.getCoordinateReferenceSystem(),
					CRS.decode(projection))))
		return wkt;

	SimpleFeatureCollection featureCollection = null;
	FileDataStore store;
	store = FileDataStoreFinder.getDataStore(buildShpFilePath());
	featureSource = store.getFeatureSource();
	featureCollection = featureSource.getFeatures();
	nativeBounds = featureCollection.getBounds();

	boolean needsReproject = false;
	MathTransform transform = null;
	if (projection != null) {
		CoordinateReferenceSystem crsFeatures = featureSource.getSchema().getCoordinateReferenceSystem();
		CoordinateReferenceSystem crsMap = (projection != null) ? CRS.decode(projection) : nativeBounds
				.getCoordinateReferenceSystem();
		needsReproject = !CRS.equalsIgnoreMetadata(crsFeatures, crsMap);
		transform = CRS.findMathTransform(crsFeatures, crsMap, true);
	}
	if (featureCollection != null) {
		String tmp = new String("GEOMETRYCOLLECTION ( ");
		SimpleFeatureIterator iterator = featureCollection.features();
		while (iterator.hasNext()) {
			SimpleFeature feature = iterator.next();
			Geometry geo = (Geometry) feature.getDefaultGeometry();

			if (geo.isValid() && geo.isSimple()) {
				if (needsReproject) {
					geo = JTS.transform(geo, transform);
				}
				WKTWriter ww = new WKTWriter();
				String multipolyStr = ww.writeFormatted(geo);
				tmp += multipolyStr;

				if (iterator.hasNext())
					tmp += ", ";
			}
		}
		iterator.close();
		tmp += " ) ";

		boolean dumpWKT = false;
		if (dumpWKT)
			dumpWktString(tmp);

		if (projection == null || CRS.equalsIgnoreMetadata(nativeBounds.getCoordinateReferenceSystem(), CRS.decode(projection))) {
			wkt = tmp;
		}
		retval = tmp;
	}
	return retval;
}
 
開發者ID:lizardtechblog,項目名稱:ExpressZip,代碼行數:61,代碼來源:VectorLayer.java


注:本文中的org.geotools.referencing.CRS.equalsIgnoreMetadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。