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


Java MathTransform.isIdentity方法代码示例

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


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

示例1: reprojectToEqualArea

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的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

示例2: crsMatch

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * Tests whether 2 {@link CoordinateReferenceSystem}s are equivalent
 *
 * @param sourceCrs
 *            The first {@link CoordinateReferenceSystem} to test
 * @param targetCrs
 *            The second {@link CoordinateReferenceSystem} to test
 */
public static boolean crsMatch(CoordinateReferenceSystem sourceCrs,
        CoordinateReferenceSystem targetCrs) {
    if (sourceCrs == null) {
        if (targetCrs == null) {
            return true;
        } else {
            return false;
        }
    } else if (targetCrs == null) {
        return false;
    }

    MathTransform transform;
    try {
        transform = CRS.findOperation(sourceCrs, targetCrs, null).getMathTransform();
        return transform.isIdentity();
    } catch (FactoryException e) {
        /*
         * There is a problem performing the transfer. Say that these CRSs
         * do not match (since we can't be sure)
         */
        return false;
    }
}
 
开发者ID:Reading-eScience-Centre,项目名称:edal-java,代码行数:33,代码来源:GISUtils.java

示例3: reprojectToEqualArea

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
private static Geometry reprojectToEqualArea(CoordinateReferenceSystem sourceCRS,
        Geometry sourceGeometry) throws FactoryException, TransformException {
    // Reproject to the Lambert Equal Area

    final ReferencedEnvelope env = new ReferencedEnvelope(sourceGeometry.getEnvelopeInternal(),
            sourceCRS);
    // Geometry center used for centering the reprojection on the Geometry(reduces distance artifacts)
    double lat = env.getMedian(1);
    double lon = env.getMedian(0);
    // 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, CRS.decode("EPSG:4326"), true);
    Point centerRP = (Point) JTS.transform(center, transPoint);
    lon = centerRP.getY();
    lat = centerRP.getX();
    // Creation of a wkt for the selected Geometry
    String wkt = UrbanGridProcess.PROJ_4326.replace("%LAT0%", String.valueOf(lat));
    wkt = wkt.replace("%LON0%", String.valueOf(lon));
    // 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, true);
    // Geometry reprojection
    Geometry geoPrj;
    if (!trans.isIdentity()) {
        geoPrj = JTS.transform(sourceGeometry, trans);
    } else {
        geoPrj = sourceGeometry;
    }
    return geoPrj;
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:33,代码来源:UrbanGridProcessTest.java

示例4: transformPosition

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * Transforms the given HorizontalPosition to a new position in the given
 * coordinate reference system.
 *
 * @param pos
 *            The position to translate.
 * @param targetCrs
 *            The CRS to translate into
 * @return a new position in the given CRS, or the same position if the new
 *         CRS is the same as the point's CRS. The returned point's CRS will
 *         be set to {@code targetCrs}. If the CRS of the position is null,
 *         the CRS will simply be set to the targetCrs.
 * @throws NullPointerException
 *             if {@code targetCrs} is null.
 */
public static HorizontalPosition transformPosition(HorizontalPosition pos,
        CoordinateReferenceSystem targetCrs) {
    if (pos == null) {
        return null;
    }
    CoordinateReferenceSystem sourceCrs = pos.getCoordinateReferenceSystem();
    if (sourceCrs == null) {
        return new HorizontalPosition(pos.getX(), pos.getY(), targetCrs);
    }
    if (targetCrs == null) {
        throw new NullPointerException("Target CRS cannot be null");
    }
    /*
     * CRS.findMathTransform() caches recently-used transform objects so we
     * should incur no large penalty for multiple invocations
     */
    try {
        MathTransform transform = CRS.findOperation(sourceCrs, targetCrs, null)
                .getMathTransform();
        if (transform.isIdentity())
            return pos;
        double[] point = new double[] { pos.getX(), pos.getY() };
        transform.transform(point, 0, point, 0, 1);
        return new HorizontalPosition(point[0], point[1], targetCrs);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Reading-eScience-Centre,项目名称:edal-java,代码行数:44,代码来源:GISUtils.java

示例5: transformWgs84Heading

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * Transforms the given lat-lon heading to a different
 * {@link CoordinateReferenceSystem}
 *
 * @param heading
 *            The heading in degrees
 * @param position
 *            The {@link HorizontalPosition} at which to transform the
 *            heading. The {@link CoordinateReferenceSystem} returned by
 *            {@link HorizontalPosition#getCoordinateReferenceSystem()} will
 *            be the {@link CoordinateReferenceSystem} in which the heading
 *            is valid.
 *
 * @return The heading, in degrees clockwise from "upwards" (i.e. y-positive
 *         in the target CRS)
 */
public static Double transformWgs84Heading(Number heading, HorizontalPosition position) {
    if (position.getCoordinateReferenceSystem() == null) {
        throw new NullPointerException("Target CRS cannot be null");
    }
    if (heading == null || Double.isNaN(heading.doubleValue())) {
        return null;
    }
    /*
     * CRS.findMathTransform() caches recently-used transform objects so we
     * should incur no large penalty for multiple invocations
     */
    try {
        MathTransform wgs2crs = CRS.findOperation(CommonCRS.WGS84.normalizedGeographic(),
                position.getCoordinateReferenceSystem(), null).getMathTransform();
        if (wgs2crs.isIdentity())
            return heading.doubleValue();
        heading = heading.doubleValue() * DEG2RAD;

        /*
         * Find the position in WGS84
         */
        double[] point = new double[] { position.getX(), position.getY() };
        wgs2crs.inverse().transform(point, 0, point, 0, 1);

        /*
         * Now find the derivative at that position.
         */
        Matrix derivative = wgs2crs.derivative(new DirectPosition2D(point[0], point[1]));

        /*
         * Use the derivative to find the new heading
         */
        double x = Math.sin(heading.doubleValue());
        double y = Math.cos(heading.doubleValue());

        double newX = derivative.getElement(0, 0) * x + derivative.getElement(0, 1) * y;
        double newY = derivative.getElement(1, 0) * x + derivative.getElement(1, 1) * y;

        return RAD2DEG * Math.atan2(newX, newY);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:Reading-eScience-Centre,项目名称:edal-java,代码行数:61,代码来源:GISUtils.java

示例6: transformRequestEnvelope

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * transforms (if necessary) the requested envelope into the CRS used by
 * this reader.
 *
 * @throws DataSourceException
 */
public static void transformRequestEnvelope(
		final GeoWaveRasterReaderState state,
		final CoordinateReferenceSystem crs )
		throws DataSourceException {

	if (CRS.equalsIgnoreMetadata(
			state.getRequestedEnvelope().getCoordinateReferenceSystem(),
			crs)) {
		state.setRequestEnvelopeXformed(state.getRequestedEnvelope());

		return; // and finish
	}

	try {
		/** Buffered factory for coordinate operations. */

		// transforming the envelope back to the dataset crs in
		final MathTransform transform = OPERATION_FACTORY.createOperation(
				state.getRequestedEnvelope().getCoordinateReferenceSystem(),
				crs).getMathTransform();

		if (transform.isIdentity()) { // Identity Transform ?
			state.setRequestEnvelopeXformed(state.getRequestedEnvelope());
			return; // and finish
		}

		state.setRequestEnvelopeXformed(CRS.transform(
				transform,
				state.getRequestedEnvelope()));
		state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
				crs);

		// if (config.getIgnoreAxisOrder() == false) { // check for axis
		// order
		// required
		final int indexX = indexOfX(crs);
		final int indexY = indexOfY(crs);
		final int indexRequestedX = indexOfX(state.getRequestedEnvelope().getCoordinateReferenceSystem());
		final int indexRequestedY = indexOfY(state.getRequestedEnvelope().getCoordinateReferenceSystem());

		// x Axis problem ???
		if ((indexX == indexRequestedY) && (indexY == indexRequestedX)) {
			state.setAxisSwap(true);
			final Rectangle2D tmp = new Rectangle2D.Double(
					state.getRequestEnvelopeXformed().getMinimum(
							1),
					state.getRequestEnvelopeXformed().getMinimum(
							0),
					state.getRequestEnvelopeXformed().getSpan(
							1),
					state.getRequestEnvelopeXformed().getSpan(
							0));
			state.setRequestEnvelopeXformed(new GeneralEnvelope(
					tmp));
			state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
					crs);
		}
		else if ((indexX == indexRequestedX) && (indexY == indexRequestedY)) {
			// everything is fine
		}
		else {
			throw new DataSourceException(
					"Unable to resolve the X Axis problem");
		}
		// }
	}
	catch (final Exception e) {
		throw new DataSourceException(
				"Unable to create a coverage for this source",
				e);
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:79,代码来源:GeoWaveRasterReader.java


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