本文整理汇总了Java中org.opengis.referencing.crs.CoordinateReferenceSystem类的典型用法代码示例。如果您正苦于以下问题:Java CoordinateReferenceSystem类的具体用法?Java CoordinateReferenceSystem怎么用?Java CoordinateReferenceSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CoordinateReferenceSystem类属于org.opengis.referencing.crs包,在下文中一共展示了CoordinateReferenceSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
@Override
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
Envelope envelope = (Envelope) super.parse(instance, node, value);
// handle the box CRS
CoordinateReferenceSystem crs = this.crs;
if (node.hasAttribute("srsName")) {
URI srs = (URI) node.getAttributeValue("srsName");
crs = CRS.decode(srs.toString());
}
if(crs != null) {
return ReferencedEnvelope.create(envelope, crs);
} else {
return envelope;
}
}
示例2: forceSchemaCRS
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* This method is used to force the creation of a .prj file.
* <p>
* The internally cached FeatureType will be removed, so the next call to getSchema() will read
* in the created file. This method is not thread safe and will have dire consequences for any
* other thread making use of the shapefile.
* <p>
*
* @param crs
*/
public void forceSchemaCRS(CoordinateReferenceSystem crs) throws IOException {
if (crs == null)
throw new NullPointerException("CRS required for .prj file");
String s = toSingleLineWKT(crs);
StorageFile storageFile = shpFiles.getStorageFile(PRJ);
FileWriter out = new FileWriter(storageFile.getFile());
try {
out.write(s);
} finally {
out.close();
}
storageFile.replaceOriginal();
entries.clear();
}
示例3: createSearchEnv
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
private ReferencedEnvelope createSearchEnv(final DirectPosition2D pos, final double radius) {
final CoordinateReferenceSystem contextCRS = getMapContent().getCoordinateReferenceSystem();
ReferencedEnvelope env = new ReferencedEnvelope(pos.x - radius, pos.x + radius, pos.y - radius, pos.y + radius,
contextCRS);
if (isTransformRequired()) {
final Layer layer = layerRef.get();
if (layer != null) {
final CoordinateReferenceSystem layerCRS = layer.getFeatureSource().getSchema()
.getCoordinateReferenceSystem();
try {
env = env.transform(layerCRS, true);
} catch (final Exception ex) {
throw new IllegalStateException(ex);
}
}
}
return env;
}
示例4: getPixelFromGeo
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Computes the subpixel (i.e. precision greater than integer) location of a map coordinates
* @param xgeo is the longitude
* @param ygeo is the latitude
* @param inputEpsgProjection is the projection system of (xgeo, ygeo) (for instance "EPSG:4326"). if null use the original projection
* @return [xpixel, ypixel]
*
*/
public double[] getPixelFromGeo(double xgeo, double ygeo, String inputEpsgProjection) {
double[] out = new double[]{xgeo, ygeo};
if (inputEpsgProjection != null) {
try {
double[] temp = new double[]{xgeo, ygeo, 0};
CoordinateReferenceSystem crs = CRS.decode(inputEpsgProjection);
MathTransform math = CRS.findMathTransform(crs, sourceCRS);
math.transform(temp, 0, temp, 0, 1);
out[0] = temp[0];
out[1] = temp[1];
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
}
geo2pix.transform(out, 0, out, 0, 1);
out[0] = out[0];
out[1] = out[1];
return out;
}
示例5: getGeoFromPixel
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Computes the map coordinates given the pixel location in the image reference
* @param xpix the pixel location in x
* @param ypix the pixel location in y
* @param outputEpsgProjection is the projection system of the result (for instance "EPSG:4326") if null use the original projection
* @return [longitude, latitude]
*
*
*/
public double[] getGeoFromPixel(double xpix, double ypix, String outputEpsgProjection) {
double[] out = new double[2];
pix2geo.transform(new double[]{xpix , ypix }, 0, out, 0, 1);
//pix2geo.transform(new double[]{xpix + m_translationX, ypix + m_translationY}, 0, out, 0, 1);
if (outputEpsgProjection != null) {
try {
double[] temp = new double[3];
CoordinateReferenceSystem crs = CRS.decode(outputEpsgProjection);
MathTransform math = CRS.findMathTransform(sourceCRS, crs);
math.transform(new double[]{out[0], out[1], 0}, 0, temp, 0, 1);
out[0] = temp[0];
out[1] = temp[1];
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
}
return out;
}
示例6: getPixelFromGeo
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
*
*/
public double[] getPixelFromGeo(double xgeo, double ygeo, String inputEpsgProjection) {
double[] out = new double[]{xgeo, ygeo};
if (inputEpsgProjection != null) {
try {
double[] temp = new double[]{xgeo, ygeo, 0};
CoordinateReferenceSystem crs = CRS.decode(inputEpsgProjection);
MathTransform math = CRS.findMathTransform(crs, sourceCRS);
math.transform(temp, 0, temp, 0, 1);
out[0] = temp[0];
out[1] = temp[1];
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
}
geo2pix.transform(out, 0, out, 0, 1);
return out;
}
示例7: getGeoFromPixel
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
public double[] getGeoFromPixel(double xpix, double ypix, String outputEpsgProjection) {
double[] out = new double[2];
pix2geo.transform(new double[]{xpix, ypix}, 0, out, 0, 1);
if (outputEpsgProjection != null) {
try {
double[] temp = new double[3];
CoordinateReferenceSystem crs = CRS.decode(outputEpsgProjection);
MathTransform math = CRS.findMathTransform(sourceCRS, crs);
math.transform(new double[]{out[0], out[1], 0}, 0, temp, 0, 1);
out[0] = temp[0];
out[1] = temp[1];
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
}
return out;
}
示例8: createFeatureType
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
public SimpleFeatureType createFeatureType(Geometry newGeometry, String uuid, CoordinateReferenceSystem coordinateReferenceSystem) {
String namespace = "http://www.52north.org/" + uuid;
SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
if (coordinateReferenceSystem == null) {
coordinateReferenceSystem = getDefaultCRS();
}
typeBuilder.setCRS(coordinateReferenceSystem);
typeBuilder.setNamespaceURI(namespace);
Name nameType = new NameImpl(namespace, "Feature-" + uuid);
typeBuilder.setName(nameType);
typeBuilder.add("GEOMETRY", newGeometry.getClass());
SimpleFeatureType featureType;
featureType = typeBuilder.buildFeatureType();
return featureType;
}
示例9: merge
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
private Optional<ReferencedEnvelope> merge(final ReferencedEnvelope oldEnv,
final Collection<ReferencedEnvelope> dirtyList) {
final CoordinateReferenceSystem declaredCrs = oldEnv.getCoordinateReferenceSystem();
return dirtyList.stream()
.map(env->{
if(env instanceof ReferencedEnvelope3D) {
return new ReferencedEnvelope(env, CRS.getHorizontalCRS(env.getCoordinateReferenceSystem()));
} else {
return env;
}
})
.map(env->{
try {
return env.transform(declaredCrs, true, 1000);
} catch (TransformException | FactoryException e) {
throw new RuntimeException("Error while merging bounding boxes",e);
}
})
.reduce((env1, env2)->{ReferencedEnvelope x = new ReferencedEnvelope(env1); x.expandToInclude(env2); return x;});
}
示例10: registerAbstractGeometryTypeBinding
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
public static void registerAbstractGeometryTypeBinding(final Configuration config, Map bindings,
QName qName) {
//use setter injection for AbstractGeometryType bindign to allow an
// optional crs to be set in teh binding context for parsing, this crs
// is set by the binding of a parent element.
// note: it is important that this component adapter is non-caching so
// that the setter property gets updated properly every time
bindings.put(
qName,
new SetterInjectionComponentAdapter(
qName, AbstractGeometryTypeBinding.class,
new Parameter[]{
new OptionalComponentParameter(CoordinateReferenceSystem.class),
new DirectObjectParameter(config, Configuration.class),
new DirectObjectParameter(getSrsSyntax(config), SrsSyntax.class)
}
)
);
}
示例11: configureBindings
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void configureBindings(Map bindings) {
//register our custom bindings
bindings.put(OGC.FilterType, FilterTypeBinding.class);
bindings.put(OGC.PropertyNameType,
PropertyNameTypeBinding.class);
bindings.put(GML.CircleType, CircleTypeBinding.class);
WFSXmlUtils_ISO.registerAbstractGeometryTypeBinding(this, bindings, GML.AbstractGeometryType);
// use setter injection for OGCBBoxTypeBinding to allow an
// optional crs to be set in teh binding context for parsing, this crs
// is set by the binding of a parent element.
// note: it is important that this component adapter is non-caching so
// that the setter property gets updated properly every time
bindings.put(
OGC.BBOXType,
new SetterInjectionComponentAdapter(OGC.BBOXType,
OGCBBOXTypeBinding.class,
new Parameter[] { new OptionalComponentParameter(CoordinateReferenceSystem.class) }));
// override XSQName binding
bindings.put(XS.QNAME, XSQNameBinding.class);
}
示例12: getDeclaredCrs
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Returns the declared CRS given the native CRS and the request WFS version
*
* @param nativeCRS
* @param wfsVersion
*
*/
public static CoordinateReferenceSystem getDeclaredCrs(CoordinateReferenceSystem nativeCRS,
String wfsVersion) {
try {
if(nativeCRS == null)
return null;
if (wfsVersion.equals("1.0.0")) {
return nativeCRS;
} else {
String code = GML2EncodingUtils.epsgCode(nativeCRS);
//it's possible that we can't do the CRS -> code -> CRS conversion...so we'll just return what we have
if (code == null) return nativeCRS;
return CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:" + code);
}
} catch (Exception e) {
throw new WFSException("We have had issues trying to flip axis of " + nativeCRS, e);
}
}
示例13: toShapeFile
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* write a shapefile representing the grid in a coordinate ref system ex :
* "EPSG:2975" -> RGR92, "EPSG:2154" -> L93, "EPSG:4326" -> WGS84
*
* @param fileName
* @param epsg
*/
public void toShapeFile(String fileName, String epsg) {
FT_FeatureCollection<IFeature> pop = new FT_FeatureCollection<>();
System.out.println("writing..." + fileName);
for (int i = 0; i < nbRows(); ++i)
for (int j = 0; j < nbCols(); ++j)
pop.add(new DefaultFeature(tiles[i][j]));
CRSAuthorityFactory factory = CRS.getAuthorityFactory(true);
CoordinateReferenceSystem crs = null;
try {
crs = factory.createCoordinateReferenceSystem(epsg);
} catch (FactoryException e) {
e.printStackTrace();
}
ShapefileWriter.write(pop, fileName, crs);
System.out.println("writing done");
}
示例14: compareCarteRecale
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
*
* @param reseauRecale1
* @param reseauRecale2
* @throws Exception
*/
private void compareCarteRecale(CarteTopo reseauRecale1, CarteTopo reseauRecale2) throws Exception {
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
GML encode = new GML(Version.WFS1_0);
encode.setNamespace("geotools", "http://geotools.org");
// Arcs recales du reseau 1
SimpleFeatureCollection arcs1 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale1.getPopArcs(), sourceCRS);
ByteArrayOutputStream output1 = new ByteArrayOutputStream();
encode.encode(output1, arcs1);
// Arcs recales du reseau 2
SimpleFeatureCollection arcs2 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale2.getPopArcs(), sourceCRS);
ByteArrayOutputStream output2 = new ByteArrayOutputStream();
encode.encode(output2, arcs2);
// On compare : est-ce que le XML est comparable ????
assertXMLEqual(output1.toString(), output2.toString());
}
示例15: getCRSCode
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Gets the CRS code.
*
* @param coordinateReferenceSystem the coordinate reference system
* @return the CRS code
*/
public String getCRSCode(CoordinateReferenceSystem coordinateReferenceSystem) {
ReferenceIdentifier identifier = null;
if (coordinateReferenceSystem != null) {
Set<ReferenceIdentifier> indentifierList = coordinateReferenceSystem.getIdentifiers();
if (indentifierList != null) {
if (indentifierList.iterator().hasNext()) {
identifier = indentifierList.iterator().next();
}
}
}
String code = NOT_SET_CRS;
if (identifier != null) {
ValueComboBoxData data = crsMap.get(identifier.toString());
if (data != null) {
code = data.getKey();
}
}
return code;
}