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


Java DirectPosition类代码示例

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


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

示例1: getGeoPosition

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
/**
 * Convert {@link DirectPosition} into a {@link GeoPosition}
 * 
 * @param position
 * @return Returns a {@link GeoPosition}
 */
private static GeoPosition getGeoPosition(final DirectPosition position) {

	double latitude = 0;
	double longitude = 0;
	final int dimension = position.getDimension();

	for (int dimensionIndex = 0; dimensionIndex < dimension; dimensionIndex++) {

		if (dimensionIndex == 0) {
			longitude = position.getOrdinate(dimensionIndex);
		} else if (dimensionIndex == 1) {
			latitude = position.getOrdinate(dimensionIndex);
		}
	}

	return new GeoPosition(latitude, longitude);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:24,代码来源:MapProviderManager.java

示例2: getPixelSize

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
/**
 * Utility methods
 */

private double[] getPixelSize(GeoCoding sourceGeoCoding, CoordinateReferenceSystem targetCRS) {
    double[] size = null;
    try {
        size = new double[2];
        DirectPosition geoPos1 = sourceGeoCoding.getImageToMapTransform()
                .transform(new DirectPosition2D(0, 0), null);
        Coordinate c1 = new Coordinate(geoPos1.getOrdinate(0), geoPos1.getOrdinate(1));
        DirectPosition geoPos2 = sourceGeoCoding.getImageToMapTransform()
                .transform(new DirectPosition2D(0, 1), null);
        Coordinate c2 = new Coordinate(geoPos2.getOrdinate(0), geoPos2.getOrdinate(1));
        DirectPosition geoPos3 = sourceGeoCoding.getImageToMapTransform()
                .transform(new DirectPosition2D(1, 0), null);
        Coordinate c3 = new Coordinate(geoPos3.getOrdinate(0), geoPos3.getOrdinate(1));
        final CoordinateReferenceSystem sourceCRS = sourceGeoCoding.getMapCRS();
        size[0] = distance(sourceCRS, targetCRS, c3, c1);
        size[1] = distance(sourceCRS, targetCRS, c2, c1);
    } catch (TransformException tex) {
        tex.printStackTrace();
    }
    return size;
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:26,代码来源:S2tbxMosaicOp.java

示例3: getValidSurroundingPoints

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
private List<Coordinate> getValidSurroundingPoints( WritableRandomIter outIter, GridGeometry2D gridGeometry, int c, int r )
        throws TransformException {
    List<Coordinate> coords = new ArrayList<>();
    for( int dc = -1; dc <= 1; dc++ ) {
        for( int dr = -1; dr <= 1; dr++ ) {
            if (dc == 0 && dr == 0) {
                continue;
            }
            double value = outIter.getSampleDouble(c + dc, r + dr, 0);
            if (!isNovalue(value)) {
                DirectPosition worldPosition = gridGeometry.gridToWorld(new GridCoordinates2D(c + dc, r + dr));
                double[] coordinate = worldPosition.getCoordinate();
                Coordinate pointCoordinate = new Coordinate(coordinate[0], coordinate[1]);
                pointCoordinate.z = value;
                coords.add(pointCoordinate);
            }

        }
    }
    return coords;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:22,代码来源:OmsHoleFiller.java

示例4: expandToIncludeEnvelope

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
private void expandToIncludeEnvelope( ReferencedEnvelope maxExtent, org.opengis.geometry.Envelope envelope ) {
    ReferencedEnvelope tmpExtent = new ReferencedEnvelope(envelope.getCoordinateReferenceSystem());
    DirectPosition ll = envelope.getLowerCorner();
    double[] coordinate = ll.getCoordinate();
    tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
    DirectPosition ur = envelope.getUpperCorner();
    coordinate = ur.getCoordinate();
    tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));

    try {
        ReferencedEnvelope transformed = tmpExtent.transform(maxExtent.getCoordinateReferenceSystem(), true);
        maxExtent.expandToInclude(transformed);
    } catch (TransformException | FactoryException e) {
        e.printStackTrace();
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:ImageGenerator.java

示例5: getRegionArrayFromGridCoverage

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
/**
 * Get the array of region parameters covered by the {@link GridCoverage2D coverage}. 
 * 
 * @param gridCoverage the coverage.
 * @return the array of region parameters as [n, s, w, e, xres, yres, cols, rows]
 */
public static double[] getRegionArrayFromGridCoverage( GridCoverage2D gridCoverage ) {
    Envelope envelope = gridCoverage.getEnvelope();
    DirectPosition lowerCorner = envelope.getLowerCorner();
    double[] westSouth = lowerCorner.getCoordinate();
    DirectPosition upperCorner = envelope.getUpperCorner();
    double[] eastNorth = upperCorner.getCoordinate();

    GridGeometry2D gridGeometry = gridCoverage.getGridGeometry();
    GridEnvelope2D gridRange = gridGeometry.getGridRange2D();
    int height = gridRange.height;
    int width = gridRange.width;

    AffineTransform gridToCRS = (AffineTransform) gridGeometry.getGridToCRS();
    double xRes = XAffineTransform.getScaleX0(gridToCRS);
    double yRes = XAffineTransform.getScaleY0(gridToCRS);

    double[] params = new double[]{eastNorth[1], westSouth[1], westSouth[0], eastNorth[0], xRes, yRes, width, height};

    return params;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:27,代码来源:CoverageUtilities.java

示例6: getPointES

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
private Double getPointES(GridCoverage2D raster, Point point) {
    Double result = null;
    try {
        DirectPosition position = JTS.toDirectPosition(point.getCoordinate(), GeometryUtils.WGS_84_CRS);
        double[] resultArray = raster.evaluate(position, (double[]) null);
        if (resultArray[0] != RASTER_NO_DATA_VALUE) {
            result = resultArray[0];
        } else {
            LOGGER.debug(String.format(ES_NOT_FOUND_NO_DATA_MESSAGE, point.getX(), point.getY()));
        }
    } catch (PointOutsideCoverageException e) {
        // Ignore the exception - if the point is outside of the raster area, the result is null
        LOGGER.debug(String.format(ES_NOT_FOUND_OUTSIDE_AREA_MESSAGE, point.getX(), point.getY()));
    }
    return result;
}
 
开发者ID:SEEG-Oxford,项目名称:ABRAID-MP,代码行数:17,代码来源:EnvironmentalSuitabilityHelper.java

示例7: exampleReferencedEnvelope

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
private void exampleReferencedEnvelope() throws Exception {
    // exampleReferencedEnvelope start
    ReferencedEnvelope envelope = new ReferencedEnvelope(0, 10, 0, 20, DefaultGeographicCRS.WGS84);
    
    double xMin = envelope.getMinX();
    double yMin = envelope.getMinY();
    
    double xMax = envelope.getMaxX();
    double yMax = envelope.getMaxY();
    
    double width = envelope.getWidth();
    double height = envelope.getHeight();
    
    double xCenter = envelope.getMedian(0);
    double yCenter = envelope.getMedian(1);
    
    CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
    int dimension = envelope.getDimension();
    
    // Direct access to internal upper and lower positions
    DirectPosition lower = envelope.getLowerCorner();
    DirectPosition upper = envelope.getUpperCorner();
    
    // expand to include 15, 30
    envelope.include(15, 30);
    
    envelope.isEmpty(); // check if storing width and height are 0
    
    envelope.isNull(); // check if "null" (not storing anything)
    envelope.setToNull();
    
    // exampleReferencedEnvelope end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:34,代码来源:APIExamples.java

示例8: exampleGridCoverageDirect

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
void exampleGridCoverageDirect() throws Exception {
    double x =0;
    double y = 0;
    CoordinateReferenceSystem crs = null;
    
    File file = new File("test.tiff");
    AbstractGridFormat format = GridFormatFinder.findFormat(file);
    GridCoverage2DReader reader = format.getReader(file);
    // exampleGridCoverageDirect start
    GridCoverage2D coverage = reader.read(null);
    
    // direct access
    DirectPosition position = new DirectPosition2D( crs, x, y);
    
    double[] sample = (double[]) coverage.evaluate( position ); // assume double
    
    // resample with the same array
    sample = coverage.evaluate( position, sample );
    // exampleGridCoverageDirect end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:21,代码来源:CoverageExamples.java

示例9: transformJTSGeometry

import org.opengis.geometry.DirectPosition; //导入依赖的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

示例10: toCoordinates

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
public double[] toCoordinates(Position position) {
  checkNotNull(position, "Position cannot be null.");
  DirectPosition directPosition = position.getDirectPosition();
  checkArgument(directPosition != null, "Direct position cannot be null.");
  CoordinateReferenceSystem coordinateReferenceSystem = directPosition
      .getCoordinateReferenceSystem();
  checkArgument(coordinateReferenceSystem != null,
      "Coordinate reference system cannot be null.");
  checkArgument(coordinateReferenceSystem.equals(positionFactory
      .getCoordinateReferenceSystem()),
      "Invalid coordinate reference system: " + coordinateReferenceSystem);
  double[] coordinates = directPosition.getCoordinate();
  checkArgument(coordinates != null, "Coordinates cannot be null.");
  checkArgument(coordinates.length == 2,
      "Invalid number of Position coordinates: " + coordinates.length);
  return coordinates;
}
 
开发者ID:enriquedacostacambio,项目名称:iotake-suller,代码行数:18,代码来源:GeoToolsGeometryProvider.java

示例11: createPosition

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
private Position createPosition(boolean nullDirectPosition,
    CoordinateReferenceSystem coordinateReferenceSystem,
    double... coordinates) {
  DirectPosition directPosition = null;
  if (!nullDirectPosition) {
    directPosition = createMock(DirectPosition.class);
    expect(directPosition.getCoordinateReferenceSystem()).andReturn(
        coordinateReferenceSystem);
    expect(directPosition.getCoordinate()).andReturn(coordinates);
    replay(directPosition);
  }

  Position position = createMock(Position.class);
  expect(position.getDirectPosition()).andReturn(directPosition);
  replay(position);
  return position;
}
 
开发者ID:enriquedacostacambio,项目名称:iotake-suller,代码行数:18,代码来源:GeoToolsGeometryProviderTest.java

示例12: withPosition

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
@Test
public void withPosition() {
  long id = 123;
  double longitude = 53.15;
  double latitude = 42.6;
  EasyDocument document = new EasyDocument(id, WithPositon.class,
      WithPositon.class, Object.class).set("WithPositon__id", id).set(
      "WithPositon__position", longitude + " " + latitude);
  WithPositon bean = binder.getBean(document);
  assertEquals(id, bean.id);
  assertNotNull(bean.position);
  DirectPosition directPosition = bean.position.getDirectPosition();
  assertNotNull(directPosition);
  double[] coordinate = directPosition.getCoordinate();
  assertNotNull(coordinate);
  assertEquals(2, coordinate.length);
  assertEquals(longitude, coordinate[0], Double.MIN_VALUE);
  assertEquals(latitude, coordinate[1], Double.MIN_VALUE);
}
 
开发者ID:enriquedacostacambio,项目名称:iotake-suller,代码行数:20,代码来源:PositionExtractITest.java

示例13: fetchElevation

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
/**
 * Gets elevation for a coordinate giving (lat,lon). Note that latitude
 * corresponds to the 'x' member of each coordinate, despite any unfortunate
 * clash with the use of x for horizontal cartesian coordinates.
 * @param l
 * @return
 * @throws DataUnavailableException If a non-recoverable error stops the data
 *  from being accessed. Less serious errors simply result in null elevations
 *  being returned.
 * @throws
 */
@Override
public Double fetchElevation(Coordinate point) throws DataUnavailableException {
	if( wrap ) {
		// Convert coordinates to valid lat=(-90,90], lon=[-180,180)
		point = ProjectionTools.wrapCoordinate(point);
	} else {
		if( point.x <= -90 || 90 < point.x ||
				point.y < -180 || 180 <= point.y ) {
			// Coordinates off the map
			return null;
		}
	}
	GridCoverage2D grid = loadGrid(point);
	// Change from (lat,lon) convention to (x,y)
	DirectPosition pos = new DirectPosition2D(point.y,point.x);
	double elev = grid.evaluate(pos,(double[])null)[0];
	return elev;
}
 
开发者ID:sbliven,项目名称:earthcraft,代码行数:30,代码来源:GridCoverageElevationProvider.java

示例14: eastNorthToLatLong

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
public static Coordinate eastNorthToLatLong(double x, double y, String sourceCrs, String targetCrs) throws FactoryException, MismatchedDimensionException, TransformException {
    CoordinateReferenceSystem targetCrsDecoded = CRS.decode(targetCrs);
    CoordinateReferenceSystem sourceCrsDecoded = CRS.decode(sourceCrs);

    CoordinateOperation op = new DefaultCoordinateOperationFactory().createOperation(sourceCrsDecoded, targetCrsDecoded);

    DirectPosition source = new GeneralDirectPosition(x, y);
    DirectPosition target = op.getMathTransform().transform(source, null);
    Double targetX = target.getOrdinate(0);
    Double targetY = target.getOrdinate(1);

    return new Coordinate(targetY, targetX);
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:14,代码来源:CoordinateUtils.java

示例15: WKTPoint

import org.opengis.geometry.DirectPosition; //导入依赖的package包/类
/**
 * Instantiates a new WKT point.
 *
 * @param pt the pt
 */
public WKTPoint(DirectPosition pt) {

    if (pt != null) {
        this.x = pt.getCoordinate()[0];
        this.y = pt.getCoordinate()[1];
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:13,代码来源:WKTPoint.java


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