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


Java DefaultGeographicCRS.WGS84属性代码示例

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


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

示例1: FeatureLayer

public FeatureLayer(LayerType layerType, final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
                    PropertySet configuration) {
    super(layerType, configuration);
    crs = fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
    if (crs == null) {
        // todo - check me! Why can this happen??? (nf)
        crs = DefaultGeographicCRS.WGS84;
    }
    final ReferencedEnvelope envelope = new ReferencedEnvelope(fc.getBounds(), crs);
    modelBounds = new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(),
                                         envelope.getWidth(), envelope.getHeight());
    mapContext = new DefaultMapContext(crs);
    final Style style = (Style) configuration.getValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE);
    mapContext.addLayer(fc, style);
    renderer = new StreamingRenderer();
    workaroundLabelCacheBug();
    style.accept(new RetrievingStyleVisitor());
    renderer.setContext(mapContext);

}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:20,代码来源:FeatureLayer.java

示例2: initialise

/**
 * Initialise the WKTParser object.
 */
private static void initialise() {
    Hints hints = new Hints(Hints.CRS, DefaultGeographicCRS.WGS84);

    PositionFactory positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
    GeometryFactory geometryFactory = GeometryFactoryFinder.getGeometryFactory(hints);
    PrimitiveFactory primitiveFactory = GeometryFactoryFinder.getPrimitiveFactory(hints);
    AggregateFactory aggregateFactory = GeometryFactoryFinder.getAggregateFactory(hints);

    wktParser = new WKTParser(geometryFactory, primitiveFactory, positionFactory,
            aggregateFactory);

    wktTypeList.add(new WKTType(WKT_POINT, false, 1, "Point", false, false));
    wktTypeList.add(new WKTType(WKT_MULTIPOINT, true, 1, "Point", true, false));
    wktTypeList.add(new WKTType(WKT_LINESTRING, false, 2, "Line", false, false));
    wktTypeList.add(new WKTType("LINEARRING", false, 2, "Line", false, false));
    wktTypeList.add(new WKTType(WKT_MULTILINESTRING, true, 2, "Line", true, false));
    wktTypeList.add(new WKTType(WKT_POLYGON, false, -1, "Polygon", false, true));
    wktTypeList.add(new WKTType(WKT_MULTIPOLYGON, true, -1, "Polygon", true, true));

    for (WKTType wkyType : wktTypeList) {
        wktTypeMap.put(wkyType.getName(), wkyType);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:26,代码来源:WKTConversion.java

示例3: NLSDEMTask

public NLSDEMTask(String apiKey, URI prjFileLocation, String tiffStorage) throws URISyntaxException {
    if (prjFileLocation == null)
        // Fallback to EPSG3067 found within JAR
        prjFileLocation = NLSDEMTask.class.getResource("EPSG3067.prj").toURI();

    if (tiffStorage == null)
        tiffStorage = System.getProperty("java.io.tmpdir");

    Path prjFile = Paths.get(prjFileLocation);
    if (!Files.isReadable(prjFile))
        throw new IllegalArgumentException(
                ".prj file " + prjFileLocation + " cannot be read. See that it exists and is readable!");

    this.sourceCRS = DefaultGeographicCRS.WGS84;
    try {
        PrjFileReader reader = new PrjFileReader(FileChannel.open(prjFile, StandardOpenOption.READ));
        targetCRS = reader.getCoordinateReferenceSystem();
        transform = CRS.findMathTransform(sourceCRS, targetCRS);
    } catch (FactoryException | IOException e) {
        throw new IllegalArgumentException(".prj file provided is invalid!", e);
    }
    this.nlsXmlClient = new NLSXMLClient(apiKey, tiffStorage);
    this.tiffDownloaderService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
            new NLSTiffDownloaderFactory());
}
 
开发者ID:jsimomaa,项目名称:osmosis-nls-dem,代码行数:25,代码来源:NLSDEMTask.java

示例4: testBasic

@Test
public void testBasic() throws NoSuchAuthorityCodeException, TransformException, FactoryException {
    ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84);
    int width = 8;
    int height = 4;
    int pixelsPerCell = 1;
    String strategy = "Basic";
    List<String> strategyArgs = null;
    Float emptyCellValue = null;
    Float scaleMin = 0f;
    Float scaleMax = null;
    boolean useLog = false;

    GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, strategyArgs, emptyCellValue, scaleMin, scaleMax, useLog, envelope, width, height, null);
    checkInternal(coverage, fineDelta);
    checkEdge(coverage, envelope, fineDelta);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:GeoHashGridProcessTest.java

示例5: testScaled

@Test
public void testScaled() throws NoSuchAuthorityCodeException, TransformException, FactoryException {
    ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84);
    int width = 16;
    int height = 8;
    int pixelsPerCell = 1;
    String strategy = "Basic";
    List<String> strategyArgs = null;
    Float emptyCellValue = null;
    Float scaleMin = 0f;
    Float scaleMax = null;
    boolean useLog = false;

    GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, strategyArgs, emptyCellValue, scaleMin, scaleMax, useLog, envelope, width, height, null);
    checkInternal(coverage, fineDelta);
    checkEdge(coverage, envelope, fineDelta);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:GeoHashGridProcessTest.java

示例6: testSubCellCrop

@Test
public void testSubCellCrop() throws NoSuchAuthorityCodeException, TransformException, FactoryException {
    ReferencedEnvelope envelope = new ReferencedEnvelope(-168.75,168.75,-78.75,78.75,DefaultGeographicCRS.WGS84);
    int width = 16;
    int height = 8;
    int pixelsPerCell = 1;
    String strategy = "Basic";
    List<String> strategyArgs = null;
    Float emptyCellValue = null;
    Float scaleMin = 0f;
    Float scaleMax = null;
    boolean useLog = false;

    GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, strategyArgs, emptyCellValue, scaleMin, scaleMax, useLog, envelope, width, height, null);
    checkInternal(coverage, fineDelta);
    checkEdge(coverage, envelope, fineDelta);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:GeoHashGridProcessTest.java

示例7: testSubCellCropWithSheer

@Test
public void testSubCellCropWithSheer() throws NoSuchAuthorityCodeException, TransformException, FactoryException {
    ReferencedEnvelope envelope = new ReferencedEnvelope(-168.75,168.75,-78.75,78.75,DefaultGeographicCRS.WGS84);
    int width = 900;
    int height = 600;
    int pixelsPerCell = 1;
    String strategy = "Basic";
    List<String> strategyArgs = null;
    Float emptyCellValue = null;
    Float scaleMin = 0f;
    Float scaleMax = null;
    boolean useLog = false;

    GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, strategyArgs, emptyCellValue, scaleMin, scaleMax, useLog, envelope, width, height, null);
    checkInternal(coverage, fineDelta);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:16,代码来源:GeoHashGridProcessTest.java

示例8: testGeoHashGrid

@Test
public void testGeoHashGrid() throws Exception {
    features = TestUtil.createAggregationFeatures(ImmutableList.of(
            ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(-89.9,-179.9),1),"doc_count",10)))
            ));
    ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84);
    geohashGrid.initalize(envelope, features);
    assertEquals(GeoHash.widthDegrees(1), geohashGrid.getCellWidth(), 1e-10);
    assertEquals(GeoHash.heightDegrees(1), geohashGrid.getCellHeight(), 1e-10);
    assertEquals(new Envelope(-180+GeoHash.widthDegrees(1)/2.,180-GeoHash.widthDegrees(1)/2.,-90+GeoHash.heightDegrees(1)/2.,90-GeoHash.heightDegrees(1)/2.), geohashGrid.getEnvelope());
    int ny = (int) Math.round(180/geohashGrid.getCellHeight());
    int nx = (int) Math.round(360/GeoHash.widthDegrees(1));
    float[][] expected = new float[ny][nx];
    expected[ny-1][0] = 10;
    assertEquals(ny, geohashGrid.getGrid().length);
    assertEquals(nx, geohashGrid.getGrid()[0].length);
    IntStream.range(0, ny).forEach(i->assertTrue(Arrays.equals(expected[i], geohashGrid.getGrid()[i])));
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:18,代码来源:GeoHashGridTest.java

示例9: testGeoHashGrid_scaled

@Test
public void testGeoHashGrid_scaled() throws Exception {
    features = TestUtil.createAggregationFeatures(ImmutableList.of(
            ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(-89.9,-179.9),1),"doc_count",20))),
            ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(89.9,179.9),1),"doc_count",30)))
            ));
    ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84);
    geohashGrid.setScale(new RasterScale(5f, 10f));
    geohashGrid.initalize(envelope, features);
    assertEquals(GeoHash.widthDegrees(1), geohashGrid.getCellWidth(), 1e-10);
    assertEquals(GeoHash.heightDegrees(1), geohashGrid.getCellHeight(), 1e-10);
    assertEquals(new Envelope(-180+GeoHash.widthDegrees(1)/2.,180-GeoHash.widthDegrees(1)/2.,-90+GeoHash.heightDegrees(1)/2.,90-GeoHash.heightDegrees(1)/2.), geohashGrid.getEnvelope());
    int ny = (int) Math.round(180/geohashGrid.getCellHeight());
    int nx = (int) Math.round(360/GeoHash.widthDegrees(1));
    assertEquals(ny, geohashGrid.getGrid().length);
    assertEquals(nx, geohashGrid.getGrid()[0].length);
    float[][] expected = new float[ny][nx];
    expected[0][7] = 10;
    expected[ny-1][0] = 5;
    IntStream.range(0, ny).forEach(i->assertTrue(Arrays.equals(geohashGrid.getGrid()[i], expected[i])));
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:21,代码来源:GeoHashGridTest.java

示例10: exampleReferencedEnvelope

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,代码行数:33,代码来源:APIExamples.java

示例11: readGridcoverageImageForTile

/**
 * 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,代码行数:34,代码来源:MBTilesHelper.java

示例12: testWithGeotools

public void testWithGeotools() throws MatrixException {
    Coordinate c1 = new Coordinate(11, 46, 0);
    Coordinate c2 = new Coordinate(11.001, 46.001, 0);

    GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
    gc.setStartingGeographicPoint(c1.x, c1.y);
    gc.setDestinationGeographicPoint(c2.x, c2.y);
    double orthodromicDistance = gc.getOrthodromicDistance();

    ENU enu = new ENU(c1);
    Coordinate ce1 = enu.wgs84ToEnu(c1);
    Coordinate ce2 = enu.wgs84ToEnu(c2);

    double distance = ce1.distance(ce2);
    assertTrue(isDeltaOk(orthodromicDistance, distance));
    
    Coordinate c1Back = enu.enuToWgs84(ce1);
    Coordinate c2Back = enu.enuToWgs84(ce2);
    
    assertEquals(0, c1.distance(c1Back), 0.000001);
    assertEquals(0, c2.distance(c2Back), 0.000001);
    
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:23,代码来源:TestENU.java

示例13: SimpleMonetDBFeatureReader

public SimpleMonetDBFeatureReader(String sql, Connection conn, SimpleMonetDBFeatureSource featureSource, SimpleFeatureType featureType, Hints hints, int srid ) 
throws SQLException {
    init( featureSource, featureType, hints );
    
    this.srid = srid;
    
    CoordinateReferenceSystem sourceCrs = featureType.getGeometryDescriptor().getCoordinateReferenceSystem();
    CoordinateReferenceSystem targetCrs = DefaultGeographicCRS.WGS84;
    try {
        targetCrs = CRS.decode("EPSG:3857");
        boolean lenient = true;
        mathTransform = CRS.findMathTransform(sourceCrs, targetCrs, lenient);
    } catch (Exception ex) {
        Logger.getLogger(SimpleMonetDBFeatureReader.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    //create the result set
    this.conn = conn;
    st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    rs = st.executeQuery(sql);
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb-simple,代码行数:21,代码来源:SimpleMonetDBFeatureReader.java

示例14: getCalculatorWGS84

public static IGeoCalculator getCalculatorWGS84()
{
  if (calcWGS84 == null)
  {
    calcWGS84 = new GeotoolsCalculator(DefaultGeographicCRS.WGS84);
  }

  return calcWGS84;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:9,代码来源:GeoSupport.java

示例15: initalize

public GeoHashGrid initalize(ReferencedEnvelope srcEnvelope, SimpleFeatureCollection features) throws NoSuchAuthorityCodeException, TransformException, FactoryException {
    this.buckets = readFeatures(features);

    final String firstGeohash = buckets.isEmpty() ? null : (String) buckets.get(0).get("key");
    final int precision;
    if (firstGeohash == null || !isValid(firstGeohash)) {
        LOGGER.fine("No aggregations found or missing/invalid geohash key");
        precision = DEFAULT_PRECISION;
    } else {
        precision = ((String) buckets.get(0).get("key")).length();
    }

    cellWidth = GeoHash.widthDegrees(precision);
    cellHeight = GeoHash.heightDegrees(precision);

    if (srcEnvelope.getCoordinateReferenceSystem() != null) {
        srcEnvelope = srcEnvelope.transform(DefaultGeographicCRS.WGS84,false);
    }
    computeMinLonOffset(srcEnvelope);
    envelope = computeEnvelope(srcEnvelope, precision);

    boundingBox = new ReferencedEnvelope(envelope.getMinX()-cellWidth/2.0, envelope.getMaxX()+cellWidth/2.0,
            envelope.getMinY()-cellHeight/2.0, envelope.getMaxY()+cellHeight/2.0, DefaultGeographicCRS.WGS84);

    final int numCol = (int) Math.round((envelope.getMaxX()-envelope.getMinX())/cellWidth+1);
    final int numRow = (int) Math.round((envelope.getMaxY()-envelope.getMinY())/cellHeight+1);
    grid = new float[numRow][numCol];
    LOGGER.fine("Created grid with size (" + numCol + ", " + numRow + ")");

    if (emptyCellValue != 0) {
        for (float[] row: grid)
            Arrays.fill(row, emptyCellValue);
    }
    List<GridCell> cells = new ArrayList<>();
    buckets.stream().forEach(bucket -> {
        Number rasterValue =  computeCellValue(bucket);
        cells.add(new GridCell((String) bucket.get("key"), rasterValue));
        scale.prepareScale(rasterValue.floatValue());
    });
    cells.stream().forEach(cell -> updateGrid(cell.getGeohash(), cell.getValue()));
    LOGGER.fine("Read " + cells.size() + " aggregation buckets");
    return this;
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:43,代码来源:GeoHashGrid.java


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