本文整理汇总了Java中org.osgeo.proj4j.CoordinateReferenceSystem类的典型用法代码示例。如果您正苦于以下问题:Java CoordinateReferenceSystem类的具体用法?Java CoordinateReferenceSystem怎么用?Java CoordinateReferenceSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoordinateReferenceSystem类属于org.osgeo.proj4j包,在下文中一共展示了CoordinateReferenceSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fromHK80toWGS84
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
private static Pair<Double, Double> fromHK80toWGS84(Pair<Double, Double> pair) {
try {
// reference: blog.tiger-workshop.com/hk1980-grid-to-wgs84/
CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
CRSFactory csFactory = new CRSFactory();
CoordinateReferenceSystem HK80 = csFactory.createFromParameters("EPSG:2326", "+proj=tmerc +lat_0=22.31213333333334 +lon_0=114.1785555555556 +k=1 +x_0=836694.05 +y_0=819069.8 +ellps=intl +towgs84=-162.619,-276.959,-161.764,0.067753,-2.24365,-1.15883,-1.09425 +units=m +no_defs");
CoordinateReferenceSystem WGS84 = csFactory.createFromParameters("WGS84", "+proj=longlat +datum=WGS84 +no_defs");
CoordinateTransform trans = ctFactory.createTransform(HK80, WGS84);
ProjCoordinate p = new ProjCoordinate();
ProjCoordinate p2 = new ProjCoordinate();
p.x = pair.first;
p.y = pair.second;
trans.transform(p, p2);
return new Pair<>(p2.x, p2.y);
} catch (IllegalStateException e) {
Timber.e(e);
}
return null;
}
开发者ID:alvinhkh,项目名称:buseta,代码行数:20,代码来源:BusRouteStopUtil.java
示例2: fromName
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Create a projection from the coordinate authority and code name
*
* @param authorityProjections
* authority projections
* @param code
* coordinate code
* @return projection
*/
private static Projection fromName(
AuthorityProjections authorityProjections, String code) {
Projection projection = null;
String name = coordinateName(authorityProjections.getAuthority(), code);
try {
CoordinateReferenceSystem crs = csFactory.createFromName(name);
projection = new Projection(authorityProjections.getAuthority(),
code, crs);
authorityProjections.addProjection(projection);
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create projection from name: "
+ name, e);
}
return projection;
}
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:28,代码来源:ProjectionFactory.java
示例3: transform
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Convert geometry to different coordinate system given the source/target
* proj4 parameters. Presumably these were pulled from SPATIAL_REF_SYS.
*
* @param geom
* @param srcParams
* @param tgtParams
* @return
* @throws FunctionExecutionException
*/
public static Geometry transform(Geometry geom,
String srcParams,
String tgtParams)
throws FunctionExecutionException {
CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
CRSFactory crsFactory = new CRSFactory();
CoordinateReferenceSystem srcCrs = crsFactory.createFromParameters(null, srcParams);
CoordinateReferenceSystem tgtCrs = crsFactory.createFromParameters(null, tgtParams);
CoordinateTransform coordTransform = ctFactory.createTransform(srcCrs, tgtCrs);
return transformGeometry(coordTransform, geom);
}
开发者ID:kenweezy,项目名称:teiid,代码行数:26,代码来源:GeometryTransformUtils.java
示例4: createFromExtra
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
private static CoordinateReferenceSystem createFromExtra(String auth, String code) {
Proj4FileReader r = new Proj4FileReader();
InputStream in = Proj.class.getResourceAsStream("other.extra");
try {
try {
return csFactory.createFromParameters(auth+":"+code, r.readParameters(code, in));
}
finally {
if(in != null){
in.close();
}
}
}
catch(IOException e) {
Log.d(Proj.class.getSimpleName(),String.format("Failure creating crs %s:%s from extra", auth, code));
return null;
}
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:21,代码来源:Proj.java
示例5: transform
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Transforms the referenced envelope to the specified coordinate reference system
* using the specified amount of points.
* <p>
* This method can handle the case where the envelope contains the North or South pole,
* or when it cross the +180° longitude.
*
* @param targetCRS The target coordinate reference system.
* @param lenient {@code true} if datum shift should be applied even if there is
* insuffisient information. Otherwise (if {@code false}), an
* exception is thrown in such case.
* @param numPointsForTransformation The number of points to use for sampling the envelope.
* @return The transformed envelope.
* @throws FactoryException if the math transform can't be determined.
* @throws TransformException if at least one coordinate can't be transformed.
*
* @see CRS#transform(CoordinateOperation, org.opengis.geometry.Envelope)
*
* @since 2.3
*/
public ReferencedEnvelope transform(final CoordinateReferenceSystem targetCRS, final int numPointsForTransformation){
if( this.crs == null ){
// really this is a the code that created this ReferencedEnvelope
throw new NullPointerException("Unable to transform referenced envelope, crs has not yet been provided.");
}
/*
* Gets a first estimation using an algorithm capable to take singularity in account
* (North pole, South pole, 180° longitude). We will expand this initial box later.
*/
CoordinateTransformFactory txFactory = new CoordinateTransformFactory();
CoordinateTransform tx = txFactory.createTransform(crs, targetCRS);
Envelope transformed = Proj.reproject(envelope, crs, targetCRS);
/*
* Now expands the box using the usual utility methods.
*/
//JTS.transform(this, target, transform, numPointsForTransformation);
// -->
Envelope expanded = transform(this.envelope,transformed, tx, numPointsForTransformation);
return new ReferencedEnvelope(expanded, targetCRS);
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:45,代码来源:ReferencedEnvelope.java
示例6: getCRS
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* returns the CoordinateReferenceSystem of this dataset, if available
* null otherwise
*/
@Override
public CoordinateReferenceSystem getCRS() {
if(mCRS == null){
String proj = dataset.GetProjection();
if (proj != null && (!proj.equals(""))) {
try{
mCRS = Proj.crs(proj);
}catch(RuntimeException e){
Log.e(GDALDataset.class.getSimpleName(), "error parsing proj "+proj);
return null;
}
}else{
return null;
}
}
return mCRS;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:26,代码来源:GDALDataset.java
示例7: latlon2twd97
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
public static ProjCoordinate latlon2twd97(LatLng latLng) {
CoordinateReferenceSystem crs1 = mCsFactory.createFromParameters(EPSG_WGS84, FUNC_WGS84);
CoordinateReferenceSystem crs2 = mCsFactory.createFromParameters(EPSG_TWD97, FUNC_TWD97);
CoordinateTransform trans = mCtFactory.createTransform(crs1, crs2);
ProjCoordinate p1 = new ProjCoordinate();
ProjCoordinate p2 = new ProjCoordinate();
p1.x = latLng.longitude;
p1.y = latLng.latitude;
trans.transform(p1, p2);
return p2;
}
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:14,代码来源:ProjFuncs.java
示例8: latlon2twd67
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
public static ProjCoordinate latlon2twd67(LatLng latLng) {
CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
CRSFactory csFactory = new CRSFactory();
CoordinateReferenceSystem crs1 = csFactory.createFromParameters(EPSG_WGS84, FUNC_WGS84);
CoordinateReferenceSystem crs2 = csFactory.createFromParameters(EPSG_TWD67, FUNC_TWD67);
CoordinateTransform trans = ctFactory.createTransform(crs1, crs2);
ProjCoordinate p1 = new ProjCoordinate();
ProjCoordinate p2 = new ProjCoordinate();
p1.x = latLng.longitude;
p1.y = latLng.latitude;
trans.transform(p1, p2);
return p2;
}
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:16,代码来源:ProjFuncs.java
示例9: fromDefinition
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Create a projection from the WKT definition
*
* @param authorityProjections
* authority projections
* @param code
* coordinate code
* @param definition
* WKT coordinate definition
* @return projection
*/
private static Projection fromDefinition(
AuthorityProjections authorityProjections, String code,
String definition) {
Projection projection = null;
if (definition != null && !definition.isEmpty()) {
String parametersString = "";
// TODO parse WKT definition into proj4 parameters
// Try to create the projection from the parameters
if (parametersString != null && !parametersString.isEmpty()) {
try {
CoordinateReferenceSystem crs = csFactory
.createFromParameters(
coordinateName(
authorityProjections.getAuthority(),
code), parametersString);
projection = new Projection(
authorityProjections.getAuthority(), code, crs);
authorityProjections.addProjection(projection);
} catch (Exception e) {
logger.log(Level.WARNING,
"Failed to create projection for authority: "
+ authorityProjections.getAuthority()
+ ", code: " + code + ", definition: "
+ definition + ", parameters: "
+ parametersString, e);
}
}
}
return projection;
}
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:48,代码来源:ProjectionFactory.java
示例10: fromParams
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Create a projection from the proj4 parameters
*
* @param authorityProjections
* authority projections
* @param code
* coordinate code
* @param params
* proj4 parameters
* @return projection
*/
private static Projection fromParams(
AuthorityProjections authorityProjections, String code,
String[] params) {
Projection projection = null;
if (params != null && params.length > 0) {
try {
CoordinateReferenceSystem crs = csFactory.createFromParameters(
coordinateName(authorityProjections.getAuthority(),
code), params);
projection = new Projection(
authorityProjections.getAuthority(), code, crs);
authorityProjections.addProjection(projection);
} catch (Exception e) {
logger.log(
Level.WARNING,
"Failed to create projection for authority: "
+ authorityProjections.getAuthority()
+ ", code: " + code + ", parameters: "
+ Arrays.toString(params), e);
}
}
return projection;
}
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:38,代码来源:ProjectionFactory.java
示例11: fromProperties
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Create a projection from configured coordinate properties
*
* @param authorityProjections
* authority projections
* @param code
* coordinate code
* @return projection
*/
private static Projection fromProperties(
AuthorityProjections authorityProjections, String code) {
Projection projection = null;
String parameters = ProjectionRetriever.getProjection(
authorityProjections.getAuthority(), code);
if (parameters != null && !parameters.isEmpty()) {
try {
CoordinateReferenceSystem crs = csFactory.createFromParameters(
coordinateName(authorityProjections.getAuthority(),
code), parameters);
projection = new Projection(
authorityProjections.getAuthority(), code, crs);
authorityProjections.addProjection(projection);
} catch (Exception e) {
logger.log(Level.WARNING,
"Failed to create projection for authority: "
+ authorityProjections.getAuthority()
+ ", code: " + code + ", parameters: "
+ parameters, e);
}
}
return projection;
}
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:37,代码来源:ProjectionFactory.java
示例12: Projection
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Constructor
*
* @param authority
* coordinate authority
* @param code
* coordinate code
* @param crs
* crs
* @since 1.3.0
*/
public Projection(String authority, String code,
CoordinateReferenceSystem crs) {
if (authority == null || code == null || crs == null) {
throw new IllegalArgumentException(
"All projection arguments are required. authority: "
+ authority + ", code: " + code + ", crs: " + crs);
}
this.authority = authority;
this.code = code;
this.crs = crs;
}
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:23,代码来源:Projection.java
示例13: validateParameters
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* a reproject operation must provide a target projection
*
* if the provided params contain such an array and the values are valid
* (not NAN) true is returned
* otherwise false
*/
@Override
public boolean validateParameters(Map<Key, Serializable> params) {
if(params == null || !params.containsKey(Reproject.KEY_REPROJECT_TARGET_CRS)){
return false;
}
String wkt = (String) params.get(Reproject.KEY_REPROJECT_TARGET_CRS);
//if this is a proj parameter string convert to wkt
if(wkt != null && wkt.startsWith("+proj")){
wkt = Proj.proj2wkt(wkt);
}
//try to create a CoordinateReferenceSystem from it
if(wkt!= null){
try{
CoordinateReferenceSystem crs = Proj.crs(wkt);
return crs != null;
}catch(RuntimeException e){
Log.e(Reproject.class.getSimpleName(), "error parsing target projection String "+wkt);
return false;
}
}else{
return false;
}
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:34,代码来源:Reproject.java
示例14: crs
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* creates a CRS from an EGSP identifier code
* @param epsg
* @return the crs or null
*/
public static CoordinateReferenceSystem crs(int epsg) {
final String _epsg = "EPSG:" + epsg;
if (_epsg.equalsIgnoreCase("epsg:900913")) {
return EPSG_900913 != null ? EPSG_900913 : createFromExtra("epsg", "900913");
}
return csFactory.createFromName(_epsg);
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:16,代码来源:Proj.java
示例15: transform
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* creates a CoordinateTransform object from two crs
* @param from the source crs
* @param to the target crs
* @return the coordinateTransform object which can be used to transform geometries
*/
public static CoordinateTransform transform(CoordinateReferenceSystem from, CoordinateReferenceSystem to) {
CoordinateTransform tx = txFactory.createTransform(from, to);
if (tx == null) {
throw new IllegalArgumentException("Unable to find transform from " + from + " to " + to);
}
return tx;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:16,代码来源:Proj.java
示例16: Raster
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
public Raster(Envelope pBounds, CoordinateReferenceSystem pCrs, Rect pSize, List<Band> pBands, ByteBuffer pData, Hashtable<?, ?> pMetaData) {
this.bounds = pBounds;
this.crs = pCrs;
this.dimension = pSize;
this.bands = pBands;
this.data = pData;
this.metadata = pMetaData;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:10,代码来源:Raster.java
示例17: RasterQuery
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
public RasterQuery(
final Envelope pBounds,
final CoordinateReferenceSystem pCrs,
final List<Band> pBands,
final Rect pDimension,
final DataType pDatatype) {
this.bounds = pBounds;
this.crs = pCrs;
this.bands = pBands;
this.dimension = pDimension;
this.datatype = pDatatype;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:14,代码来源:RasterQuery.java
示例18: MBTilesRasterQuery
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
public MBTilesRasterQuery(Envelope pBounds,
CoordinateReferenceSystem pCrs,
List<Band> pBands,
Rect pDimension,
DataType pDatatype,
int[] pTileCoords,
byte pZoom) {
super(pBounds, pCrs, pBands, pDimension, pDatatype);
this.tileCoords = pTileCoords;
this.zoom = pZoom;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:13,代码来源:MBTilesRasterQuery.java
示例19: GDALRasterQuery
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
public GDALRasterQuery(Envelope pBounds,
CoordinateReferenceSystem pCrs,
List<Band> pBands,
Rect pDimension,
DataType pDatatype,
Rect pTargetDimension) {
super(pBounds, pCrs, pBands, pDimension, pDatatype);
this.targetDimension = pTargetDimension;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:11,代码来源:GDALRasterQuery.java
示例20: reproject
import org.osgeo.proj4j.CoordinateReferenceSystem; //导入依赖的package包/类
/**
* Sets the srs to re-project query results to.
*
* @return This object.
*/
public Query reproject(String from, String to) {
CoordinateReferenceSystem src = from != null ? Proj.crs(from) : null;
CoordinateReferenceSystem dst = to != null ? Proj.crs(to) : null;
if (from != null && src == null) {
throw new IllegalArgumentException("Unknown crs: " + from);
}
if (to == null) {
throw new IllegalArgumentException("Unknown crs: " + to);
}
return reproject(src, dst);
}
开发者ID:flaviorda,项目名称:POSC,代码行数:18,代码来源:Query.java
注:本文中的org.osgeo.proj4j.CoordinateReferenceSystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论