當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。