Java Code Examples for org.opengis.referencing.crs.CoordinateReferenceSystem#equals()
The following examples show how to use
org.opengis.referencing.crs.CoordinateReferenceSystem#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RasterUtils.java From geowave with Apache License 2.0 | 6 votes |
public static ReferencedEnvelope getReferenceEnvelope( final GridCoverage gridCoverage, final CoordinateReferenceSystem targetCrs) { final CoordinateReferenceSystem sourceCrs = gridCoverage.getCoordinateReferenceSystem(); final Envelope sampleEnvelope = gridCoverage.getEnvelope(); final ReferencedEnvelope sampleReferencedEnvelope = new ReferencedEnvelope( new org.locationtech.jts.geom.Envelope( sampleEnvelope.getMinimum(0), sampleEnvelope.getMaximum(0), sampleEnvelope.getMinimum(1), sampleEnvelope.getMaximum(1)), gridCoverage.getCoordinateReferenceSystem()); ReferencedEnvelope projectedReferenceEnvelope = sampleReferencedEnvelope; if ((targetCrs != null) && !targetCrs.equals(sourceCrs)) { try { projectedReferenceEnvelope = sampleReferencedEnvelope.transform(targetCrs, true); } catch (TransformException | FactoryException e) { LOGGER.warn("Unable to transform envelope of grid coverage to " + targetCrs.getName(), e); } } return projectedReferenceEnvelope; }
Example 2
Source File: AbstractEnvelope.java From sis with Apache License 2.0 | 6 votes |
/** * Returns the common CRS of specified points. * * @param lowerCorner the first position. * @param upperCorner the second position. * @return their common CRS, or {@code null} if none. * @throws MismatchedReferenceSystemException if the two positions don't use equal CRS. */ static CoordinateReferenceSystem getCommonCRS(final DirectPosition lowerCorner, final DirectPosition upperCorner) throws MismatchedReferenceSystemException { ensureNonNull("lowerCorner", lowerCorner); ensureNonNull("upperCorner", upperCorner); final CoordinateReferenceSystem crs1 = lowerCorner.getCoordinateReferenceSystem(); final CoordinateReferenceSystem crs2 = upperCorner.getCoordinateReferenceSystem(); if (crs1 == null) { return crs2; } else { if (crs2 != null && !crs1.equals(crs2)) { throw new MismatchedReferenceSystemException(Errors.format(Errors.Keys.MismatchedCRS)); } return crs1; } }
Example 3
Source File: ImportTrackAction.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
static FeatureCollection<SimpleFeatureType, SimpleFeature> readTrack(Reader reader, GeoCoding geoCoding) throws IOException { CsvReader csvReader = new CsvReader(reader, new char[]{'\t', ' '}, true, "#"); SimpleFeatureType trackFeatureType = createTrackFeatureType(geoCoding); ListFeatureCollection featureCollection = new ListFeatureCollection(trackFeatureType); double[] record; int pointIndex = 0; while ((record = csvReader.readDoubleRecord()) != null) { if (record.length < 3) { throw new IOException("Illegal track file format.\n" + "Expecting tab-separated lines containing 3 values: lat, lon, data."); } float lat = (float) record[0]; float lon = (float) record[1]; double data = record[2]; final SimpleFeature feature = createFeature(trackFeatureType, geoCoding, pointIndex, lat, lon, data); if (feature != null) { featureCollection.add(feature); } pointIndex++; } if (featureCollection.isEmpty()) { throw new IOException("No track point found or all of them are located outside the scene boundaries."); } final CoordinateReferenceSystem mapCRS = geoCoding.getMapCRS(); if (!mapCRS.equals(DefaultGeographicCRS.WGS84)) { try { transformFeatureCollection(featureCollection, mapCRS); } catch (TransformException e) { throw new IOException("Cannot transform the ship track onto CRS '" + mapCRS.toWKT() + "'.", e); } } return featureCollection; }
Example 4
Source File: FeatureDataAdapter.java From geowave with Apache License 2.0 | 5 votes |
private void initCRS(String indexCrsCode) { if ((indexCrsCode == null) || indexCrsCode.isEmpty()) { indexCrsCode = GeometryUtils.DEFAULT_CRS_STR; } CoordinateReferenceSystem persistedCRS = persistedFeatureType.getCoordinateReferenceSystem(); if (persistedCRS == null) { persistedCRS = GeometryUtils.getDefaultCRS(); } final CoordinateReferenceSystem indexCRS = decodeCRS(indexCrsCode); if (indexCRS.equals(persistedCRS)) { reprojectedFeatureType = SimpleFeatureTypeBuilder.retype(persistedFeatureType, persistedCRS); transform = null; } else { reprojectedFeatureType = SimpleFeatureTypeBuilder.retype(persistedFeatureType, indexCRS); try { transform = CRS.findMathTransform(persistedCRS, indexCRS, true); if (transform.isIdentity()) { transform = null; } } catch (final FactoryException e) { LOGGER.warn("Unable to create coordinate reference system transform", e); } } statsManager = new StatsManager(this, persistedFeatureType, reprojectedFeatureType, transform); }
Example 5
Source File: GeometryUtils.java From geowave with Apache License 2.0 | 5 votes |
public static CoordinateReferenceSystem getIndexCrs(final Index[] indices) { CoordinateReferenceSystem indexCrs = null; for (final Index primaryindx : indices) { // for first iteration if (indexCrs == null) { indexCrs = getIndexCrs(primaryindx); } else { if (primaryindx.getIndexModel() instanceof CustomCrsIndexModel) { // check if indexes have different CRS if (!indexCrs.equals(((CustomCrsIndexModel) primaryindx.getIndexModel()).getCrs())) { LOGGER.error("Multiple indices with different CRS is not supported"); throw new RuntimeException("Multiple indices with different CRS is not supported"); } else { if (!indexCrs.equals(getDefaultCRS())) { LOGGER.error("Multiple indices with different CRS is not supported"); throw new RuntimeException("Multiple indices with different CRS is not supported"); } } } } } return indexCrs; }
Example 6
Source File: VectorLayerServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public List<InternalFeature> getFeatures(String layerId, CoordinateReferenceSystem crs, Filter queryFilter, NamedStyleInfo style, int featureIncludes, int offset, int maxResultSize, boolean forcePaging) throws GeomajasException { log.debug("getFeatures start on layer {}", layerId); long ts = System.currentTimeMillis(); VectorLayer layer = getVectorLayer(layerId); CrsTransform transformation = null; if ((featureIncludes & FEATURE_INCLUDE_GEOMETRY) != 0 && crs != null && !crs.equals(layer.getCrs())) { transformation = geoService.getCrsTransform(layer.getCrs(), crs); } GetFeaturesContainer container = new GetFeaturesContainer(); PipelineContext context = pipelineService.createContext(); context.put(PipelineCode.LAYER_ID_KEY, layerId); context.put(PipelineCode.LAYER_KEY, layer); context.put(PipelineCode.CRS_TRANSFORM_KEY, transformation); context.put(PipelineCode.CRS_KEY, crs); context.put(PipelineCode.FILTER_KEY, queryFilter); context.put(PipelineCode.STYLE_KEY, style); context.put(PipelineCode.FEATURE_INCLUDES_KEY, featureIncludes); context.put(PipelineCode.OFFSET_KEY, offset); context.put(PipelineCode.MAX_RESULT_SIZE_KEY, maxResultSize); context.put(PipelineCode.FORCE_PAGING_KEY, forcePaging); pipelineService.execute(PipelineCode.PIPELINE_GET_FEATURES, layerId, context, container); log.debug("getFeatures done on layer {}, time {}s", layerId, (System.currentTimeMillis() - ts) / 1000.0); return container.getFeatures(); }