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


Java DirectPosition.getCoordinate方法代码示例

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


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

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

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

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

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

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

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

示例7: convertAndDisplayBoundingBox

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
private void convertAndDisplayBoundingBox(
        Double x1,
        Double x2,
        Double y1,
        Double y2,
        CoordinateReferenceSystem sourceCRS,
        CoordinateReferenceSystem targetCRS
) throws TransformException, FactoryException {
    com.vividsolutions.jts.geom.Point p1 = convertDoublesToPoint(
            x1,
            y1,
            sourceCRS,
            targetCRS);
    com.vividsolutions.jts.geom.Point p2 = convertDoublesToPoint(
            x2,
            y2,
            sourceCRS,
            targetCRS);
    ReferencedEnvelope re = new ReferencedEnvelope(targetCRS);
    re.include(p1.getX(), p1.getY());
    re.include(p2.getX(), p2.getY());
    DirectPosition lowerCorner = re.getLowerCorner();
    DirectPosition upperCorner = re.getUpperCorner();
    if (lowerCorner != null && upperCorner != null) {
        double valX1 = lowerCorner.getCoordinate()[0];
        double valY1 = lowerCorner.getCoordinate()[1];
        double valX2 = upperCorner.getCoordinate()[0];
        double valY2 = upperCorner.getCoordinate()[1];
        if (CRS.getProjectedCRS(targetCRS) == null) {
            this.coordinateX1TextField.setText(String.valueOf(
                    Math.round(valX1 * HOUNDREDTHOUSAND) / HOUNDREDTHOUSAND
            ));
            this.coordinateY1TextField.setText(String.valueOf(
                    Math.round(valY1 * HOUNDREDTHOUSAND) / HOUNDREDTHOUSAND
            ));
            this.coordinateX2TextField.setText(String.valueOf(
                    Math.round(valX2 * HOUNDREDTHOUSAND) / HOUNDREDTHOUSAND
            ));
            this.coordinateY2TextField.setText(String.valueOf(
                    Math.round(valY2 * HOUNDREDTHOUSAND) / HOUNDREDTHOUSAND
            ));
        } else {
            this.coordinateX1TextField.setText(String.valueOf(
                    Math.round((float) valX1)
            ));
            this.coordinateY1TextField.setText(String.valueOf(
                    Math.round((float) valY1)
            ));
            this.coordinateX2TextField.setText(String.valueOf(
                    Math.round((float) valX2)
            ));
            this.coordinateY2TextField.setText(String.valueOf(
                    Math.round((float) valY2)
            ));
        }
    }
}
 
开发者ID:gdi-by,项目名称:downloadclient,代码行数:58,代码来源:WMSMapSwing.java

示例8: process

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@Execute
public void process() throws Exception {
    checkNull(inRaster);

    RandomIter rasterIter = CoverageUtilities.getRandomIterator(inRaster);
    RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inRaster);
    GridGeometry2D gridGeometry = inRaster.getGridGeometry();

    int cols = regionMap.getCols();
    int rows = regionMap.getRows();

    BufferedWriter writer = null;
    try {
        writer = new BufferedWriter(new FileWriter(inFile));
        for( int r = 0; r < rows; r++ ) {
            for( int c = 0; c < cols; c++ ) {
                double elevation = rasterIter.getSampleDouble(c, r, 0);
                if (doRemovenv && HMConstants.isNovalue(elevation)) {
                    continue;
                }
                DirectPosition position = gridGeometry.gridToWorld(new GridCoordinates2D(c, r));
                double[] coordinate = position.getCoordinate();

                StringBuilder sb = new StringBuilder();
                sb.append(coordinate[0]);
                sb.append("\t");
                sb.append(coordinate[1]);
                sb.append("\t");
                sb.append(elevation);
                sb.append("\n");
                writer.write(sb.toString());
            }
        }
    } finally {
        if (writer != null)
            writer.close();
    }

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

示例9: getRegionParamsFromGridCoverage

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
 * Get the parameters of the region covered by the {@link GridCoverage2D coverage}. 
 * 
 * @param gridCoverage the coverage.
 * @return the {@link HashMap map} of parameters. ( {@link #NORTH} and the 
 *          other static vars can be used to retrieve them.
 */
public static RegionMap getRegionParamsFromGridCoverage( GridCoverage2D gridCoverage ) {
    RegionMap envelopeParams = new RegionMap();

    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);

    envelopeParams.put(NORTH, eastNorth[1]);
    envelopeParams.put(SOUTH, westSouth[1]);
    envelopeParams.put(WEST, westSouth[0]);
    envelopeParams.put(EAST, eastNorth[0]);
    envelopeParams.put(XRES, xRes);
    envelopeParams.put(YRES, yRes);
    envelopeParams.put(ROWS, (double) height);
    envelopeParams.put(COLS, (double) width);

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

示例10: getRegionParamsFromImageMosaicReader

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
 * Get the parameters of the region covered by the {@link ImageMosaicReader}. 
 * 
 * @param reader the ImageMosaicReader.
 * @return the {@link HashMap map} of parameters. ( {@link #NORTH} and the 
 *          other static vars can be used to retrieve them.
 */
public static RegionMap getRegionParamsFromImageMosaicReader( ImageMosaicReader reader ) throws IOException {
    RegionMap envelopeParams = new RegionMap();

    Envelope envelope = reader.getOriginalEnvelope();

    DirectPosition lowerCorner = envelope.getLowerCorner();
    double[] westSouth = lowerCorner.getCoordinate();
    DirectPosition upperCorner = envelope.getUpperCorner();
    double[] eastNorth = upperCorner.getCoordinate();

    GridEnvelope2D gridRange = (GridEnvelope2D) reader.getOriginalGridRange();
    int height = gridRange.height;
    int width = gridRange.width;
    double[][] resolutionLevels = reader.getResolutionLevels();
    double xRes = resolutionLevels[0][0];
    double yRes = resolutionLevels[0][1];

    envelopeParams.put(NORTH, eastNorth[1]);
    envelopeParams.put(SOUTH, westSouth[1]);
    envelopeParams.put(WEST, westSouth[0]);
    envelopeParams.put(EAST, eastNorth[0]);
    envelopeParams.put(XRES, xRes);
    envelopeParams.put(YRES, yRes);
    envelopeParams.put(ROWS, (double) height);
    envelopeParams.put(COLS, (double) width);

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

示例11: gridGeometry2RegionParamsMap

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
public static RegionMap gridGeometry2RegionParamsMap( GridGeometry2D gridGeometry ) {
    RegionMap envelopeParams = new RegionMap();

    Envelope envelope = gridGeometry.getEnvelope2D();
    DirectPosition lowerCorner = envelope.getLowerCorner();
    double[] westSouth = lowerCorner.getCoordinate();
    DirectPosition upperCorner = envelope.getUpperCorner();
    double[] eastNorth = upperCorner.getCoordinate();

    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);

    envelopeParams.put(NORTH, eastNorth[1]);
    envelopeParams.put(SOUTH, westSouth[1]);
    envelopeParams.put(WEST, westSouth[0]);
    envelopeParams.put(EAST, eastNorth[0]);
    envelopeParams.put(XRES, xRes);
    envelopeParams.put(YRES, yRes);
    envelopeParams.put(ROWS, (double) height);
    envelopeParams.put(COLS, (double) width);

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

示例12: toPositon

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
protected void toPositon(double longitude, double latitude) {
  GeometryProvider provider = createGeometryProvider();

  Position position = provider.toPositon(longitude, latitude);
  assertNotNull(position);
  DirectPosition directPosition = position.getDirectPosition();
  assertNotNull(directPosition);

  double[] coordinates = directPosition.getCoordinate();

  assertNotNull(coordinates);
  assertArrayEquals(new double[] { longitude, latitude }, coordinates, 0);
}
 
开发者ID:enriquedacostacambio,项目名称:iotake-suller,代码行数:14,代码来源:GeometryProviderAbstractTest.java

示例13: transform2DPoint

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

示例14: process

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
@Execute
public void process() throws Exception {
    checkNull(inRaster);

    ISurfaceInterpolator interpolator;
    if (pMode.equals(IDW)) {
        interpolator = new IDWInterpolator(pBuffer);
    } else {
        interpolator = new TPSInterpolator(pBuffer);
    }

    RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inRaster);
    int rows = regionMap.getRows();
    int cols = regionMap.getCols();

    WritableRaster outWR = CoverageUtilities.renderedImage2WritableRaster(inRaster.getRenderedImage(), false);
    WritableRandomIter outIter = CoverageUtilities.getWritableRandomIterator(outWR);

    GridGeometry2D gridGeometry = inRaster.getGridGeometry();

    PreparedGeometry preparedRoi = null;
    if (inROI != null) {
        List<Geometry> roiList = FeatureUtilities.featureCollectionToGeometriesList(inROI, false, null);
        GeometryCollection gc = new GeometryCollection(roiList.toArray(GeometryUtilities.TYPE_GEOMETRY), gf);
        preparedRoi = PreparedGeometryFactory.prepare(gc);
    }
    pm.beginTask("Filling holes...", cols - 2);
    for( int c = 1; c < cols - 1; c++ ) {
        for( int r = 1; r < rows - 1; r++ ) {
            if (pm.isCanceled()) {
                return;
            }

            double value = outIter.getSampleDouble(c, r, 0);
            if (isNovalue(value)) {
                DirectPosition worldPosition = gridGeometry.gridToWorld(new GridCoordinates2D(c, r));
                double[] coordinate = worldPosition.getCoordinate();
                Coordinate pointCoordinate = new Coordinate(coordinate[0], coordinate[1]);
                Point point = gf.createPoint(pointCoordinate);
                if (preparedRoi == null || preparedRoi.intersects(point)) {

                    // TODO this could be done considering more points and more far away points.
                    // For now, this works.
                    List<Coordinate> surroundingValids = getValidSurroundingPoints(outIter, gridGeometry, c, r);
                    if (surroundingValids.size() > 3) {
                        double newValue = interpolator.getValue(surroundingValids.toArray(new Coordinate[0]),
                                pointCoordinate);
                        outIter.setSample(c, r, 0, newValue);
                    }
                }
            }
        }
        pm.worked(1);
    }
    pm.done();

    outIter.done();

    outRaster = CoverageUtilities.buildCoverage("nulled", outWR, regionMap, inRaster.getCoordinateReferenceSystem());
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:61,代码来源:OmsHoleFiller.java

示例15: processing

import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
private void processing( final int cols, final STRtree tree, final WritableRandomIter interpolatedIter, final double[] eval,
        final int row ) {
    try {
        for( int c = 0; c < cols; c++ ) {
            final DirectPosition gridToWorld = gridGeometry.gridToWorld(new GridCoordinates2D(c, row));
            // System.out.println(row + "/" + c);
            boolean doProcess = true;
            if (inMask != null) {
                inMask.evaluate(gridToWorld, eval);
                if (isNovalue(eval[0])) {
                    doProcess = false;
                }
            }

            if (doProcess) {
                final Coordinate currentCoord = new Coordinate();
                final double[] coord = gridToWorld.getCoordinate();
                currentCoord.x = coord[0];
                currentCoord.y = coord[1];

                final Envelope env = new Envelope(currentCoord.x - pBuffer, currentCoord.x + pBuffer, currentCoord.y
                        - pBuffer, currentCoord.y + pBuffer);

                @SuppressWarnings("unchecked")
                final List<Coordinate> result = tree.query(env);
                // System.out.println(row + "/" + c + "  = " + result.size());

                // we need at least 3 points
                if (result.size() < 4) {
                    continue;
                }

                final double value = interpolator.getValue(result.toArray(new Coordinate[0]), currentCoord);
                synchronized (interpolatedIter) {
                    interpolatedIter.setSample(c, row, 0, value);
                }
            }

        }
        pm.worked(1);
    } catch (TransformException e) {
        e.printStackTrace();
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:45,代码来源:OmsSurfaceInterpolator.java


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