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


Java MathTransform类代码示例

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


MathTransform类属于org.opengis.referencing.operation包,在下文中一共展示了MathTransform类的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: convertLonLatToEuclidean

import org.opengis.referencing.operation.MathTransform; //导入依赖的package包/类
@Deprecated
public static ProjectedCoordinate convertLonLatToEuclidean(
  Coordinate lonlat) {

  final MathTransform transform = getTransform(lonlat);
  final Coordinate to = new Coordinate();

  // the transform seems to swap the lat lon pairs
  Coordinate latlon = new Coordinate(lonlat.y, lonlat.x);

  try {
    JTS.transform(latlon, to,
        transform);
  } catch (final TransformException e) {
    e.printStackTrace();
  }

  return new ProjectedCoordinate(transform, new Coordinate(to.y, to.x), lonlat);
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:20,代码来源:GeoUtils.java

示例6: getTransform

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

示例8: setCrs

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

示例9: createTransformation

import org.opengis.referencing.operation.MathTransform; //导入依赖的package包/类
@Override
public void createTransformation(final MathTransform t) {
	if (t != null) {
		transformer = new GeometryCoordinateSequenceTransformer(new DefaultCoordinateSequenceTransformer(
				GeometryUtils.GEOMETRY_FACTORY.getCoordinateSequenceFactory()));
		// TODO see ConcatenatedTransformDirect2D
		transformer.setMathTransform(t);
		try {
			inverseTransformer = new GeometryCoordinateSequenceTransformer(new DefaultCoordinateSequenceTransformer(
					GeometryUtils.GEOMETRY_FACTORY.getCoordinateSequenceFactory()));
			inverseTransformer.setMathTransform(t.inverse());
		} catch (final NoninvertibleTransformException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:17,代码来源:Projection.java

示例10: CRSTransform

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

示例11: toMathTransform2D

import org.opengis.referencing.operation.MathTransform; //导入依赖的package包/类
/**
 * Returns the math transform for the two specified dimensions of the specified transform.
 *
 * @param transform The transform.
 * @param mtFactory The factory to use for extracting the sub-transform.
 *
 * @return The {@link MathTransform2D} part of {@code transform}.
 *
 * @throws FactoryException If {@code transform} is not separable.
 */
private static MathTransform2D toMathTransform2D(final MathTransform transform,
                                                 final MathTransformFactory mtFactory) throws FactoryException {
    final DimensionFilter filter = new DimensionFilter(mtFactory);
    filter.addSourceDimension(DIMENSION_X_INDEX);
    filter.addSourceDimension(DIMENSION_Y_INDEX);
    MathTransform candidate = filter.separate(transform);
    if (candidate instanceof MathTransform2D) {
        return (MathTransform2D) candidate;
    }
    filter.addTargetDimension(DIMENSION_X_INDEX);
    filter.addTargetDimension(DIMENSION_Y_INDEX);
    candidate = filter.separate(transform);
    if (candidate instanceof MathTransform2D) {
        return (MathTransform2D) candidate;
    }
    throw new FactoryException(Errors.format(ErrorKeys.NO_TRANSFORM2D_AVAILABLE));
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:28,代码来源:Reproject.java

示例12: transformEnvelope

import org.opengis.referencing.operation.MathTransform; //导入依赖的package包/类
private ReferencedEnvelope transformEnvelope(CoordinateReferenceSystem fromCRS,
                                             CoordinateReferenceSystem toCRS,
                                             Rectangle2D bounds) {
    try {
        MathTransform transform = CRS.findMathTransform(fromCRS, toCRS);
        Envelope sourceEnvelope = new Envelope(bounds.getMinX(), bounds.getMaxX(),
                bounds.getMinY(), bounds.getMaxY());
        final Envelope envelope = JTS.transform(sourceEnvelope, transform);
        return new ReferencedEnvelope(envelope.getMinX(), envelope.getMaxX(),
                envelope.getMinY(), envelope.getMaxY(),
                toCRS);
    } catch (FactoryException | TransformException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:17,代码来源:S2tbxMosaicOp.java

示例13: getCells

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

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

示例15: readGridcoverageImageForTile

import org.opengis.referencing.operation.MathTransform; //导入依赖的package包/类
/**
 * Read the image of a tile from a generic geotools coverage reader.
 * 
 * @param reader the reader, expected to be in CRS 3857.
 * @param x the tile x.
 * @param y the tile y.
 * @param zoom the zoomlevel.
 * @return the image.
 * @throws IOException 
 */
public static BufferedImage readGridcoverageImageForTile(AbstractGridCoverage2DReader reader, int x, int y,
    int zoom, CoordinateReferenceSystem resampleCrs) throws IOException {
    double north = tile2lat(y, zoom);
    double south = tile2lat(y + 1, zoom);
    double west = tile2lon(x, zoom);
    double east = tile2lon(x + 1, zoom);

    Coordinate ll = new Coordinate(west, south);
    Coordinate ur = new Coordinate(east, north);

    try {
        CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;

        MathTransform transform = CRS.findMathTransform(sourceCRS, resampleCrs);
        ll = JTS.transform(ll, null, transform);
        ur = JTS.transform(ur, null, transform);
    } catch (Exception e) {
        e.printStackTrace();
    }

    BufferedImage image =
        ImageUtilities.imageFromReader(reader, TILESIZE, TILESIZE, ll.x, ur.x, ll.y, ur.y, resampleCrs);
    return image;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:35,代码来源:MBTilesHelper.java


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