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


Java MathTransform.transform方法代码示例

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


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

示例1: getPixelFromGeo

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

示例2: getGeoFromPixel

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

示例3: getPixelFromGeo

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

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * Transform the query position into the coordinate reference system of the
 * data (if different to that of the {@code MapContext}).
 *
 * @param pos
 *            query position in {@code MapContext} coordinates
 *
 * @return query position in data ({@code MapLayer}) coordinates
 */
private DirectPosition2D getTransformed(final DirectPosition2D pos) {
	if (isTransformRequired()) {
		final MathTransform tr = getTransform();
		if (tr == null) {
			throw new IllegalStateException("MathTransform should not be null");
		}

		try {
			return (DirectPosition2D) tr.transform(pos, null);
		} catch (final Exception ex) {
			throw new IllegalStateException(ex);
		}
	}

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

示例6: initialise

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
@Override
public boolean initialise() {
	try {
		this.displayName=manifestFile.getName();
		setFile(manifestFile);
    	
    	parseProductXML(productxml);
    	
    	tiffImages = getImages();
    	//TIFF image = tiffImages.values().iterator().next();
        bounds = new Rectangle(0, 0, getMetaWidth(),getMetaHeight());
        
        gcps = getGcps();
        if (gcps == null) {
            dispose();
            return false;
        }
        //get satellite altitude
        geotransform = GeoTransformFactory.createFromGcps(gcps, "EPSG:4326");
        double radialdist = Math.pow(xposition * xposition + yposition * yposition + zposition * zposition, 0.5);
        MathTransform convert;
        double[] latlon = getGeoTransform().getGeoFromPixel(0, 0);
        double[] position = new double[3];
        convert = CRS.findMathTransform(DefaultGeographicCRS.WGS84, DefaultGeocentricCRS.CARTESIAN);
        convert.transform(latlon, 0, position, 0, 1);
        double earthradial = Math.pow(position[0] * position[0] + position[1] * position[1] + position[2] * position[2], 0.5);
        setSatelliteAltitude(radialdist - earthradial);

        // get incidence angles from gcps
        // !!possible to improve
        float firstIncidenceangle = (float) (this.gcps.get(0).getAngle());
        float lastIncidenceAngle = (float) (this.gcps.get(this.gcps.size() - 1).getAngle());
        setIncidenceNear(firstIncidenceangle < lastIncidenceAngle ? firstIncidenceangle : lastIncidenceAngle);
        setIncidenceFar(firstIncidenceangle > lastIncidenceAngle ? firstIncidenceangle : lastIncidenceAngle);

    } catch (TransformException | FactoryException | GeoTransformException ex) {
    	logger.error(ex.getMessage(),ex);
    }
    return true;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:41,代码来源:TerrasarXImage_SLC.java

示例7: addCoords

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
private void addCoords (Coordinate coords[], MathTransform transform) throws Throwable {
		for (Pair<Coordinate, Coordinate> pair : new ConsecutivePairs<Coordinate>( Arrays.asList( coords ) , true)) {
			
			double 
				x1 = pair.first().x,// - cen.getCoordinate().x, 
				y1 = pair.first().y,// - cen.getCoordinate().y,
				x2 = pair.second().x,// - cen.getCoordinate().x, 
				y2 = pair.second().y;// - cen.getCoordinate().y;

			if (targetCRS != null && transform != null)
			{
				double[] result = new double[] {x1, y1, x2, y2, 0, 0};
				transform.transform( result, 0, result, 0, 2 );
				
				addLine (
						new double[] {result[0], result[1], result[2]}, 
						new double[] {result[3], result[4], result[5]}
						);
				
			}
			else {
				
				addLine(new double[] {x1, y1}, new double[] { x2, y2} );
			}
			
//			GML2Graph.this.result.newLine(new Point2d(x1, y1), new Point2d(x2, y2));
			
		}

	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:31,代码来源:GMLReader.java

示例8: createBandImages

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * STEP 5 methods
 */

private void createBandImages() throws TransformException {
    for (Band band : this.targetProduct.getBands()) {
        Band[] srcBands = new Band[this.sourceProducts.length];
        for (int index = 0; index < this.sourceProducts.length; index++){
            for(MosaicOp.Variable outputVariable : this.variables) {
                if(outputVariable.getName().equals(band.getName())) {
                    srcBands[index] = this.sourceProducts[index].getBand(getSourceBandName(outputVariable.getExpression()));
                }
            }
        }
        final Dimension tileSize = JAIUtils.computePreferredTileSize(band.getRasterWidth(), band.getRasterHeight(), 1);
        int levels = srcBands[0].getSourceImage().getModel().getLevelCount();
        for(Product product: this.sourceProducts){
            int lowestLevel = product.getBandAt(0).getSourceImage().getModel().getLevelCount();
            if(lowestLevel < levels){
                levels = lowestLevel;
            }
        }
        MathTransform mapTransform = band.getGeoCoding().getImageToMapTransform();
        DirectPosition bandOrigin = mapTransform.transform(new DirectPosition2D(0, 0), null);
        S2MosaicMultiLevelSource bandSource =
                new S2MosaicMultiLevelSource(srcBands,
                        bandOrigin.getOrdinate(0),
                        bandOrigin.getOrdinate(1),
                        band.getRasterWidth(), band.getRasterHeight(),
                        tileSize.width, tileSize.height, levels,
                        band.getGeoCoding(),
                        this.overlappingMethod);
        band.setSourceImage(new DefaultMultiLevelImage(bandSource));
    }
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:36,代码来源:S2tbxMosaicOp.java

示例9: 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

示例10: getWorldCoordinates

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
private static Coordinate[] getWorldCoordinates(
		final double minX,
		final double minY,
		final double maxX,
		final double maxY,
		final int numPointsPerSegment,
		final MathTransform gridToCRS )
		throws MismatchedDimensionException,
		TransformException {
	final Point2D[] gridCoordinates = getGridCoordinates(
			minX,
			minY,
			maxX,
			maxY,
			numPointsPerSegment);
	final Coordinate[] worldCoordinates = new Coordinate[gridCoordinates.length];
	for (int i = 0; i < gridCoordinates.length; i++) {
		final DirectPosition2D worldPt = new DirectPosition2D();
		final DirectPosition2D dp = new DirectPosition2D(
				gridCoordinates[i]);
		gridToCRS.transform(
				dp,
				worldPt);
		worldCoordinates[i] = new Coordinate(
				worldPt.getX(),
				worldPt.getY());
	}
	return worldCoordinates;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:30,代码来源:RasterUtils.java

示例11: getPatchCoordinates

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * Returns the patch coordinates for a tile rectangle.
 *
 * @param r The tile rectangle (only {@code r.x} and {@code r.y} are used).
 * @param t The image-to-map transform used for the tile.
 *
 * @return the patch coordinates.
 *
 * @throws TransformException
 */
public Point getPatchCoordinates(Rectangle r, MathTransform t) throws TransformException {
    final DirectPosition p = new DirectPosition2D(r.getX(), r.getY());
    t.transform(p, p);

    final double lon = p.getOrdinate(0);
    final double lat = p.getOrdinate(1);

    final int patchX = getPatchX(lon);
    final int patchY = getPatchY(lat);

    return new Point(patchX, patchY);
}
 
开发者ID:bcdev,项目名称:esa-pfa,代码行数:23,代码来源:PatchGrid.java

示例12: transform2DPoint

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
public static double[] transform2DPoint(String fromEPSG, String toEPSG, double x, double y) throws FactoryException, TransformException {	
	MathTransform transform = CRS.findMathTransform(CRS.decode(fromEPSG), CRS.decode(toEPSG), false);
	DirectPosition srcPoint = new DirectPosition2D(x, y);
	DirectPosition dstPoint = new DirectPosition2D();
	transform.transform(srcPoint, dstPoint);
	
	return dstPoint.getCoordinate();
}
 
开发者ID:oscarfonts,项目名称:geocalc,代码行数:9,代码来源:Geocalc.java

示例13: initialise

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
@Override
public boolean initialise() {
	 try {

		 this.imgName=manifestFile.getParentFile().getName();

 	setFile(manifestFile);
 	parseProductXML(productxml);
 	tiffImages = getImages();

     if(tiffImages==null) return false;

        //System.out.println(reader.getNumImages(false));
        TIFF image = tiffImages.values().iterator().next();
        this.displayName= this.imgName;//image.getImageFile().getName();

        image.xSize = getWidth();
        image.ySize = getHeight();

        bounds = new Rectangle(0, 0, image.xSize, image.ySize);
        gcps = getGcps();
        if (gcps == null) {
            dispose();
            return false;
        }

        //get satellite altitude
        geotransform = GeoTransformFactory.createFromGcps(gcps, "EPSG:4326");
        double radialdist = Math.pow(xposition * xposition + yposition * yposition + zposition * zposition, 0.5);
        MathTransform convert;
        double[] latlon = getGeoTransform().getGeoFromPixel(0, 0);
        double[] position = new double[3];
        convert = CRS.findMathTransform(DefaultGeographicCRS.WGS84, DefaultGeocentricCRS.CARTESIAN);
        convert.transform(latlon, 0, position, 0, 1);
        double earthradial = Math.pow(position[0] * position[0] + position[1] * position[1] + position[2] * position[2], 0.5);
        setSatelliteAltitude(radialdist - earthradial);

        // get incidence angles from gcps
        // !!possible to improve
        float firstIncidenceangle = (float) (this.gcps.get(0).getAngle());
        float lastIncidenceAngle = (float) (this.gcps.get(this.gcps.size() - 1).getAngle());
        setIncidenceNear(firstIncidenceangle < lastIncidenceAngle ? firstIncidenceangle : lastIncidenceAngle);
        setIncidenceFar(firstIncidenceangle > lastIncidenceAngle ? firstIncidenceangle : lastIncidenceAngle);


    } catch (TransformException|FactoryException|GeoTransformException ex) {
    	dispose();
    	logger.error(ex.getMessage(),ex);
    }
    return true;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:52,代码来源:TerrasarXImage.java

示例14: buildOrigin

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
/**
 * Transform toCartesian (around x,y) to a renderable coordinate system with y-up.
 */
private Matrix4d buildOrigin( double x, double y, MathTransform toCartesian ) throws TransformException {
	
	double delta = 1e-6;
	
	double[] frame = new double[] {
			x      , y, 
			x+delta, y, 
			x      , y+delta, 
			0      , 0      ,0 };
	
	toCartesian.transform( frame, 0, frame, 0, 3 );
	
	Vector3d o = new Vector3d(frame[0], frame[1], frame[2]),
			 a = new Vector3d(frame[3], frame[4], frame[5]),
			 b = new Vector3d(frame[6], frame[7], frame[8]),
			 c = new Vector3d();
	
	a.sub( o );
	b.sub( o );
			
	a.normalize();
	b.normalize();
	
	c.cross( a, b );
	
	Matrix4d out = new Matrix4d();
	
	out.setRow( 0, -a.x, -a.y, -a.z, 0 );
	out.setRow( 1, c.x, c.y, c.z, 0 );
	out.setRow( 2, b.x, b.y, b.z, 0 );
	out.setRow( 3, 0, 0, 0, 1 );
	
	out.transform( o );
	
	out.m03 = -o.x;
	out.m13 = -o.y;
	out.m23 = -o.z;
	
	return out;
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:44,代码来源:Tweed.java

示例15: updatePositionValues

import org.opengis.referencing.operation.MathTransform; //导入方法依赖的package包/类
private void updatePositionValues() {
    final boolean availableInRaster = pixelPosValidInRaster &&
            coordinatesAreInRasterBounds(currentRaster, pixelX, pixelY, rasterLevel);
    final boolean availableInScene = isSampleValueAvailableInScene();
    final double offset = 0.5 + (pixelInfoView.getShowPixelPosOffset1() ? 1.0 : 0.0);
    final double pX = levelZeroRasterX + offset;
    final double pY = levelZeroRasterY + offset;

    String tix, tiy, tsx, tsy, tmx, tmy, tgx, tgy;
    tix = tiy = tsx = tsy = tmx = tmy = tgx = tgy = INVALID_POS_TEXT;
    GeoCoding geoCoding = currentRaster.getGeoCoding();
    if (availableInRaster) {
        if (pixelInfoView.getShowPixelPosDecimal()) {
            tix = String.valueOf(pX);
            tiy = String.valueOf(pY);
        } else {
            tix = String.valueOf((int) Math.floor(pX));
            tiy = String.valueOf((int) Math.floor(pY));
        }
    }
    if (getCurrentProduct().isMultiSize()) {
        if (!availableInScene) {
            tsx = PixelInfoViewModelUpdater.INVALID_POS_TEXT;
            tsy = PixelInfoViewModelUpdater.INVALID_POS_TEXT;
        } else {
            double sX = levelZeroSceneX + offset;
            double sY = levelZeroSceneY + offset;
            if (pixelInfoView.getShowPixelPosDecimal()) {
                tsx = String.valueOf(sX);
                tsy = String.valueOf(sY);
            } else {
                tsx = String.valueOf((int) Math.floor(sX));
                tsy = String.valueOf((int) Math.floor(sY));
            }
        }
    }
    if (availableInRaster && geoCoding != null) {
        PixelPos pixelPos = new PixelPos(pX, pY);
        GeoPos geoPos = geoCoding.getGeoPos(pixelPos, null);
        if (pixelInfoView.getShowGeoPosDecimals()) {
            tgx = String.format("%.6f", geoPos.getLon());
            tgy = String.format("%.6f", geoPos.getLat());
        } else {
            tgx = geoPos.getLonString();
            tgy = geoPos.getLatString();
        }
        if (geoCoding instanceof MapGeoCoding) {
            final MapGeoCoding mapGeoCoding = (MapGeoCoding) geoCoding;
            final MapTransform mapTransform = mapGeoCoding.getMapInfo().getMapProjection().getMapTransform();
            Point2D mapPoint = mapTransform.forward(geoPos, null);
            tmx = String.valueOf(MathUtils.round(mapPoint.getX(), 10000.0));
            tmy = String.valueOf(MathUtils.round(mapPoint.getY(), 10000.0));
        } else if (geoCoding instanceof CrsGeoCoding) {
            MathTransform transform = geoCoding.getImageToMapTransform();
            try {
                DirectPosition position = transform.transform(new DirectPosition2D(pX, pY), null);
                double[] coordinate = position.getCoordinate();
                tmx = String.valueOf(coordinate[0]);
                tmy = String.valueOf(coordinate[1]);
            } catch (TransformException ignore) {
            }
        }
    }
    int rowCount = 0;
    positionModel.updateValue(tix, rowCount++);
    positionModel.updateValue(tiy, rowCount++);
    if (getCurrentProduct().isMultiSize()) {
        positionModel.updateValue(tsx, rowCount++);
        positionModel.updateValue(tsy, rowCount++);
    }
    if (geoCoding != null) {
        positionModel.updateValue(tgx, rowCount++);
        positionModel.updateValue(tgy, rowCount++);
        if (geoCoding instanceof MapGeoCoding || geoCoding instanceof CrsGeoCoding) {
            positionModel.updateValue(tmx, rowCount++);
            positionModel.updateValue(tmy, rowCount);
        }
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:80,代码来源:PixelInfoViewModelUpdater.java


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