本文整理汇总了Java中org.opengis.referencing.crs.CoordinateReferenceSystem.equals方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateReferenceSystem.equals方法的具体用法?Java CoordinateReferenceSystem.equals怎么用?Java CoordinateReferenceSystem.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opengis.referencing.crs.CoordinateReferenceSystem
的用法示例。
在下文中一共展示了CoordinateReferenceSystem.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReferenceEnvelope
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
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 com.vividsolutions.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;
}
示例2: readTrack
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
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;
}
示例3: PointCollectionDomain
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
public PointCollectionDomain(List<HorizontalPosition> positions, VerticalPosition zPos,
DateTime time) throws MismatchedCrsException, IncorrectDomainException {
this.positions = new ImmutableArray1D<HorizontalPosition>(
positions.toArray(new HorizontalPosition[0]));
this.zPos = zPos;
this.time = time;
CoordinateReferenceSystem commonCrs = null;
double minx = Double.MAX_VALUE;
double maxx = -Double.MAX_VALUE;
double miny = Double.MAX_VALUE;
double maxy = -Double.MAX_VALUE;
for (HorizontalPosition hPos : positions) {
if (commonCrs == null) {
commonCrs = hPos.getCoordinateReferenceSystem();
} else {
if (!commonCrs.equals(hPos.getCoordinateReferenceSystem())) {
hPos = GISUtils.transformPosition(hPos, commonCrs);
}
}
if (!Double.isNaN(hPos.getX())) {
minx = Math.min(minx, hPos.getX());
maxx = Math.max(maxx, hPos.getX());
}
if (!Double.isNaN(hPos.getY())) {
miny = Math.min(miny, hPos.getY());
maxy = Math.max(maxy, hPos.getY());
}
}
bbox = new BoundingBoxImpl(minx, miny, maxx, maxy, commonCrs);
}
示例4: getIntersectionPolygon
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* Gets the intersection polygon.
*
* @param wifParameters
* the wif parameters
* @return the intersection polygon
* @throws NoSuchAuthorityCodeException
* the no such authority code exception
* @throws FactoryException
* the factory exception
* @throws ParseException
* the parse exception
* @throws MismatchedDimensionException
* the mismatched dimension exception
* @throws TransformException
* the transform exception
*/
private String getIntersectionPolygon(final Map<String, Object> wifParameters)
throws NoSuchAuthorityCodeException, FactoryException, ParseException,
MismatchedDimensionException, TransformException {
final String polyTxt = (String) wifParameters.get(WifKeys.POLYGON);
String queryTxt = "";
if (polyTxt != null) {
// default values do better with constants
final String CRS_ORG = (String) wifParameters.get(WifKeys.CRS_ORG);
final String CRS_DEST = (String) wifParameters.get(WifKeys.CRS_DEST);
String geometryColumnName = (String) wifParameters
.get(WifKeys.GEOMETRY_COLUMN_KEY);
LOGGER.debug("CRS_ORG ={} ", CRS_ORG);
if (wifParameters.get(WifKeys.CRS_ORG) == null) {
wifParameters.put(WifKeys.CRS_ORG, WifKeys.CRS_INTERFACE);
LOGGER.warn("it is null, defaulting to CRS_ORG ={} ",
wifParameters.get(WifKeys.CRS_ORG));
}
LOGGER.debug("CRS_DEST ={} ", CRS_DEST);
if (wifParameters.get(WifKeys.CRS_DEST) == null) {
wifParameters.put(WifKeys.CRS_DEST, WifKeys.CRS_DEFAULT);
LOGGER.warn("it is null, defaulting to CRS_DEST ={} ",
wifParameters.get(WifKeys.CRS_DEST));
}
if (geometryColumnName == null) {
wifParameters.put(WifKeys.GEOMETRY_COLUMN_KEY,
WifKeys.DEFAULT_COLUMN_NAME);
geometryColumnName = (String) wifParameters
.get(WifKeys.GEOMETRY_COLUMN_KEY);
LOGGER.warn("Geometry column name not specified, defaulting to ={} ",
wifParameters.get(WifKeys.GEOMETRY_COLUMN_KEY));
}
final GeometryFactory geometryFactory = JTSFactoryFinder
.getGeometryFactory(null);
final WKTReader reader = new WKTReader(geometryFactory);
LOGGER.debug("requested interception ORG polygon wkt: {}", polyTxt);
Polygon polygon = (Polygon) reader.read(polyTxt);
final CoordinateReferenceSystem orgCRS = CRS
.decode((String) wifParameters.get(WifKeys.CRS_ORG));
final CoordinateReferenceSystem targetCRS = CRS
.decode((String) wifParameters.get(WifKeys.CRS_DEST));
if (!orgCRS.equals(targetCRS)) {
LOGGER
.info("the CRS of the polygon requested is different from the uaz, attempting to transform...");
final MathTransform transform = CRS.findMathTransform(orgCRS,
targetCRS, true);
final Polygon traPoly = (Polygon) JTS.transform(polygon, transform);
LOGGER.debug("transformed polygon wkt: ", traPoly.toText());
polygon = traPoly;
}
LOGGER.debug("geometry column name: {}", geometryColumnName);
queryTxt = "INTERSECTS(" + geometryColumnName + ", " + polygon.toText()
+ ")";
}
return queryTxt;
}
示例5: main
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if( args.length < 5 ) {
System.out.println( "usage: cmd [--(discrete|shapefile)] indicator_shp indicator_fld diss_shp diss_fld output_fn" );
return;
}
int argOfs = 0;
boolean discrete = args[0].equals("--discrete");
boolean shapefile = args[0].equals("--shapefile");
if(discrete || shapefile){
argOfs=1;
}
String indicator_shp = args[argOfs+0];
String indFldExpression = args[argOfs+1];
String diss_shp = args[argOfs+2];
String dissFldExpression = args[argOfs+3];
String output_fn = args[argOfs+4];
//==== get indicator shapefile
FeatureSource<?, ?> indicatorSource = getFeatureSource(indicator_shp);
//==== get diss source
FeatureSource<?, ?> dissSource = getFeatureSource(diss_shp);
//==== make sure both shapefiles have the same CRS
CoordinateReferenceSystem crs1 = indicatorSource.getSchema().getCoordinateReferenceSystem();
CoordinateReferenceSystem crs2 = dissSource.getSchema().getCoordinateReferenceSystem();
if( !crs1.equals(crs2) ){
throw new Exception( "Coordinate systems don't match. "+crs1+"\n\n"+crs2 );
}
//==== loop through indicator shapefile, finding overlapping diss items
HashMap<Feature, ArrayList<Feature>> dissToInd = collectIndByDiss(
indicatorSource, dissSource);
if(dissToInd.size()==0){
System.out.println( "no overlaps found." );
return;
}
// register each diss with the inds, along with the ind's share of the diss's magnitude
HashMap<Feature, ArrayList<DissShare>> indDissShares = collectDissSharesByInd(
dissFldExpression, dissToInd);
// dole out the ind's magnitude in proportion to the diss's mag share, accumulating under the diss
HashMap<Feature, Double> dissMags = distributeIndToDisses(
indFldExpression, indDissShares);
// go through the dissMag list and emit points at centroids
if(shapefile){
writeToShapefile(output_fn, dissMags);
} else {
writeToCSV(discrete, output_fn, dissMags);
}
System.out.print("done.\n");
}
示例6: getFeatures
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
static List<Feature> getFeatures(String shp_filename) throws MalformedURLException, IOException {
// construct shapefile factory
File file = new File(shp_filename);
Map<String, URL> map = new HashMap<String, URL>();
map.put("url", file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
// get shapefile as generic 'feature source'
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
SimpleFeatureType schema = featureSource.getSchema();
CoordinateReferenceSystem shpCRS = schema.getCoordinateReferenceSystem();
SimpleFeatureCollection collection = featureSource.getFeatures();
SimpleFeatureIterator iterator = collection.features();
List<Feature> ret = new ArrayList<Feature>(collection.size());
if (shpCRS != null && !shpCRS.equals(DefaultGeographicCRS.WGS84)) {
try {
MathTransform transform = CRS.findMathTransform(shpCRS, DefaultGeographicCRS.WGS84, true);
while (iterator.hasNext()) {
SimpleFeature next = iterator.next();
Geometry geom = (Geometry) next.getDefaultGeometry();
next.setDefaultGeometry(JTS.transform(geom, transform));
ret.add(next);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
else {
while (iterator.hasNext()) {
ret.add(iterator.next());
}
}
return ret;
}
示例7: initCRS
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
private void initCRS(
String indexCrsCode ) {
if (indexCrsCode == null || indexCrsCode.isEmpty()) {
// TODO make sure we handle null/empty to make it default
indexCrsCode = GeometryUtils.DEFAULT_CRS_STR;
}
CoordinateReferenceSystem persistedCRS = persistedFeatureType.getCoordinateReferenceSystem();
if (persistedCRS == null) {
persistedCRS = GeometryUtils.DEFAULT_CRS;
}
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);
}
catch (final FactoryException e) {
LOGGER.warn(
"Unable to create coordinate reference system transform",
e);
}
}
statsManager = new StatsManager(
this,
persistedFeatureType,
reprojectedFeatureType,
transform);
secondaryIndexManager = new SecondaryIndexManager(
this,
persistedFeatureType,
statsManager);
}