当前位置: 首页>>代码示例>>Java>>正文


Java CRS.findMathTransform方法代码示例

本文整理汇总了Java中org.geotools.referencing.CRS.findMathTransform方法的典型用法代码示例。如果您正苦于以下问题:Java CRS.findMathTransform方法的具体用法?Java CRS.findMathTransform怎么用?Java CRS.findMathTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.referencing.CRS的用法示例。


在下文中一共展示了CRS.findMathTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGeoFromPixel

import org.geotools.referencing.CRS; //导入方法依赖的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;
  }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:GcpsGeoTransform.java

示例2: getPixelFromGeo

import org.geotools.referencing.CRS; //导入方法依赖的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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:GcpsGeoTransform.java

示例3: getPixelFromGeo

import org.geotools.referencing.CRS; //导入方法依赖的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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:21,代码来源:AffineGeoTransform.java

示例4: getGeoFromPixel

import org.geotools.referencing.CRS; //导入方法依赖的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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:18,代码来源:AffineGeoTransform.java

示例5: NLSDEMTask

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
public NLSDEMTask(String apiKey, URI prjFileLocation, String tiffStorage) throws URISyntaxException {
    if (prjFileLocation == null)
        // Fallback to EPSG3067 found within JAR
        prjFileLocation = NLSDEMTask.class.getResource("EPSG3067.prj").toURI();

    if (tiffStorage == null)
        tiffStorage = System.getProperty("java.io.tmpdir");

    Path prjFile = Paths.get(prjFileLocation);
    if (!Files.isReadable(prjFile))
        throw new IllegalArgumentException(
                ".prj file " + prjFileLocation + " cannot be read. See that it exists and is readable!");

    this.sourceCRS = DefaultGeographicCRS.WGS84;
    try {
        PrjFileReader reader = new PrjFileReader(FileChannel.open(prjFile, StandardOpenOption.READ));
        targetCRS = reader.getCoordinateReferenceSystem();
        transform = CRS.findMathTransform(sourceCRS, targetCRS);
    } catch (FactoryException | IOException e) {
        throw new IllegalArgumentException(".prj file provided is invalid!", e);
    }
    this.nlsXmlClient = new NLSXMLClient(apiKey, tiffStorage);
    this.tiffDownloaderService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
            new NLSTiffDownloaderFactory());
}
 
开发者ID:jsimomaa,项目名称:osmosis-nls-dem,代码行数:26,代码来源:NLSDEMTask.java

示例6: getTransform

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
/**
 * Get the {@code MathTransform} to reproject data from the coordinate system of
 * the {@code MapContext's} to that of the {@code MapLayer}.
 *
 * @return the transform or {@code null} if either the layer's coordinate system is the same
 *         as that of the map context, or either has a {@code null} CRS.
 */
public MathTransform getTransform() {
    if (transform == null && !transformFailed && dataCRS != null) {
        MapContent content = getMapContent();
        if (content == null) {
            throw new IllegalStateException("map context should not be null");
        }

        CoordinateReferenceSystem contextCRS = content.getCoordinateReferenceSystem();
        try {
            transform = CRS.findMathTransform(contextCRS, dataCRS, true);
        } catch (Exception ex) {
            LOGGER.warning("Can't transform map context to map layer CRS");
            transformFailed = true;
        }
    }

    return transform;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:26,代码来源:InfoToolHelper.java

示例7: setCrs

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
public void setCrs(final CoordinateReferenceSystem crs) {
	try {
		// System.out.println(content.layers().size());
		final ReferencedEnvelope rEnv = getDisplayArea();
		// System.out.println(rEnv);

		final CoordinateReferenceSystem sourceCRS = rEnv.getCoordinateReferenceSystem();
		final CoordinateReferenceSystem targetCRS = crs;

		final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
		final com.vividsolutions.jts.geom.Envelope newJtsEnv = JTS.transform(rEnv, transform);

		final ReferencedEnvelope newEnvelope = new ReferencedEnvelope(newJtsEnv, targetCRS);
		content.getViewport().setBounds(newEnvelope);
		fullExtent = null;
		doSetDisplayArea(newEnvelope);

		// ReferencedEnvelope displayArea =
		getDisplayArea();
		// System.out.println(displayArea);
	} catch (final Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:25,代码来源:SwtMapPane.java

示例8: CRSTransform

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
/**
 * CRS transform.
 *
 * @param sourceEpsgCRSCode the source epsg CRS code
 * @param targetEpsgCRSCode the target epsg CRS code
 * @return true, if successful
 */
public boolean CRSTransform(String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
	try {
   	CoordinateReferenceSystem sourceCRS = CRS.decode(sourceEpsgCRSCode);
	CoordinateReferenceSystem targetCRS = CRS.decode(targetEpsgCRSCode);
	final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false);
	this.CRStransformation=true;
	this.sourceEpsgCode=sourceEpsgCRSCode;
	this.targetEpgsgCode=targetEpsgCRSCode;
	this.rawSpatialRDD = this.rawSpatialRDD.map(new Function<T,T>()
	{
		@Override
		public T call(T originalObject) throws Exception {
			return (T) JTS.transform(originalObject,transform);
		}
	});
	return true;
	} catch (FactoryException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:31,代码来源:SpatialRDD.java

示例9: getCells

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
private Object getCells( Envelope env ) throws Exception {

        MathTransform ll2CRSTransform = CRS.findMathTransform(leafletCRS, databaseCrs);
        MathTransform crs2llTransform = CRS.findMathTransform(databaseCrs, leafletCRS);

        Polygon searchPolygonLL = GeometryUtilities.createPolygonFromEnvelope(env);
        Geometry searchPolygonLLCRS = JTS.transform(searchPolygonLL, ll2CRSTransform);

        long t1 = System.currentTimeMillis();
        List<LasCell> lasCells = LasCellsTable.getLasCells(currentConnectedDatabase, searchPolygonLLCRS, true, true, false, false,
                false);
        int size = lasCells.size();
        long t2 = System.currentTimeMillis();
        System.out.println("time: " + (t2 - t1) + " size = " + size);

        if (size == 0) {
            return null;
        }

        loadedElementsNumText.setText("" + size);

        JSONObject rootObj = cells2Json(crs2llTransform, lasCells);
        return rootObj.toString();
    }
 
开发者ID:moovida,项目名称:STAGE,代码行数:25,代码来源:LidarViewerEntryPoint.java

示例10: reprojectToEqualArea

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
/**
 * Private method which reprojects the input Geometry in the input CRS to a Lambert-Equal Area CRS used for calculating Geometry Area and
 * perimeter.
 * 
 * @param sourceCRS Source geometry CRS.
 * @param sourceGeometry Source Geometry
 * @return
 * @throws FactoryException
 * @throws TransformException
 */
private Geometry reprojectToEqualArea(CoordinateReferenceSystem sourceCRS,
        Geometry sourceGeometry) throws FactoryException, TransformException {
    // Reproject to the Lambert Equal Area
    // Geometry center used for centering the reprojection on the Geometry(reduces distance artifacts)
    Point center = sourceGeometry.getCentroid();
    // Creation of the MathTransform associated to the reprojection
    MathTransform transPoint = CRS.findMathTransform(sourceCRS, WGS84, true);
    Point centerRP = (Point) JTS.transform(center, transPoint);
    // Creation of a wkt for the selected Geometry
    String wkt = PROJ_4326.replace("%LAT0%", String.valueOf(centerRP.getY()));
    wkt = wkt.replace("%LON0%", String.valueOf(centerRP.getX()));
    // Parsing of the selected WKT
    final CoordinateReferenceSystem targetCRS = CRS.parseWKT(wkt);
    // Creation of the MathTransform associated to the reprojection
    MathTransform trans = CRS.findMathTransform(sourceCRS, targetCRS);
    // Geometry reprojection
    Geometry geoPrj;
    if (!trans.isIdentity()) {
        geoPrj = JTS.transform(sourceGeometry, trans);
    } else {
        geoPrj = sourceGeometry;
    }
    return geoPrj;
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:35,代码来源:UrbanGridProcess.java

示例11: getAreaSimple

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
public double getAreaSimple(
		Geometry polygon )
		throws Exception {
	Point centroid = polygon.getCentroid();
	CoordinateReferenceSystem equalAreaCRS = lookupUtmCrs(
			centroid.getY(),
			centroid.getX());

	MathTransform transform = CRS.findMathTransform(
			DefaultGeographicCRS.WGS84,
			equalAreaCRS,
			true);

	Geometry transformedPolygon = JTS.transform(
			polygon,
			transform);

	return transformedPolygon.getArea() * SQM_2_SQKM;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:PolygonAreaCalculator.java

示例12: RL2NwwLayer

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
public RL2NwwLayer( RL2CoverageHandler rl2Handler, Integer tileSize ) throws Exception {
    super(makeLevels(rl2Handler, tileSize));
    RasterCoverage rasterCoverage = rl2Handler.getRasterCoverage();
    this.layerName = rasterCoverage.coverage_name;

    double w = rasterCoverage.extent_minx;
    double s = rasterCoverage.extent_miny;
    double e = rasterCoverage.extent_maxx;
    double n = rasterCoverage.extent_maxy;

    double centerX = w + (e - w) / 2.0;
    double centerY = s + (n - s) / 2.0;
    Coordinate centerCoordinate = new Coordinate(centerX, centerY);

    CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
    CoordinateReferenceSystem sourceCRS = CrsUtilities.getCrsFromSrid(rasterCoverage.srid);

    MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
    centerCoordinateLL = JTS.transform(centerCoordinate, null, transform);

    this.setUseTransparentTextures(true);

}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:24,代码来源:RL2NwwLayer.java

示例13: transformJTSGeometry

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
protected Geometry transformJTSGeometry(Geometry geom, final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem crs) throws Exception {
	final MathTransform transform = CRS.findMathTransform(sourceCRS, crs, true);
	final Mutable<Boolean> anyChanged = new Mutable<Boolean>(false);
	
	geom = (Geometry) geom.clone();
	geom.apply(new CoordinateFilter() {
		@Override
		public void filter(Coordinate c) {
			DirectPosition dpFrom = new DirectPosition2D(sourceCRS, c.x, c.y);
			DirectPosition dpTo = new DirectPosition2D();
			try {
				transform.transform(dpFrom, dpTo);
				c.x = dpTo.getOrdinate(0);
				c.y = dpTo.getOrdinate(1);
				anyChanged.set(true);
			} catch (TransformException e) {
				LOG.warn("Failed to transform point " + c, e);
			}
		}
	});
	if (anyChanged.get()) {
		geom.geometryChanged();
	}
	return geom;
}
 
开发者ID:opengeospatial,项目名称:geopackager,代码行数:26,代码来源:AbstractFeatureHarvester.java

示例14: FeatureCollectionIterator

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
public FeatureCollectionIterator(
		FeatureCollection<SimpleFeatureType, SimpleFeature> features,
		int sourceEpsg) {
	if (features != null) {
		iter = features.features();
		if (sourceEpsg != targetEpsg) {
			try {
				CoordinateReferenceSystem targetCRS = CRS.decode(
						SRS_NAMESPACE + targetEpsg, true);
				CoordinateReferenceSystem sourceCRS = CRS.decode(
						SRS_NAMESPACE + sourceEpsg, true);
				transform = CRS.findMathTransform(sourceCRS, targetCRS,
						true);
			} catch (Exception e) {
				LOGGER.warn("Could not detemine source and target CRS definitions. Geometry will not be indexed!");
			}
		}
	}
}
 
开发者ID:Geodan,项目名称:solr-dataimporthandler-wfs,代码行数:20,代码来源:WFSDataSource.java

示例15: setDefaultProjection

import org.geotools.referencing.CRS; //导入方法依赖的package包/类
public void setDefaultProjection(String epsgGeoProj){
	this.defaultEpsgProjection=epsgGeoProj;
    try {
        sourceCRS = CRS.decode(epsgGeoProj);
        defaultCrs = CRS.decode(defaultEpsgProjection);
        defaultMath = CRS.findMathTransform(defaultCrs, sourceCRS);
    } catch (Exception ex) {
    	logger.error(ex.getMessage(),ex);
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:11,代码来源:GcpsGeoTransform.java


注:本文中的org.geotools.referencing.CRS.findMathTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。