Package org.opengis.referencing.crs

Examples of org.opengis.referencing.crs.GeographicCRS


     */
    @Test
    public void testPPMUnit() throws Exception {
        // Create WGS 72 CRS where we know that the EPSG defines a unique
        // Position Vector Transformation to WGS 84 with ppm = 0.219
        GeographicCRS wgs72 = (GeographicCRS) CRS.decode("EPSG:4322");
       
        // Get datum
        DefaultGeodeticDatum datum = (DefaultGeodeticDatum)wgs72.getDatum();
       
        // Get BursaWolf parameters
        BursaWolfParameters[] params = datum.getBursaWolfParameters();
       
        // Check for coherence with the value contained in the EPSG data base
View Full Code Here


    static final double MIN_LATITUDE = -89.99;
   
    public ProjectionHandler getHandler(ReferencedEnvelope renderingEnvelope, CoordinateReferenceSystem sourceCrs, boolean wrap, int maxWraps) throws FactoryException {
        CoordinateReferenceSystem crs = renderingEnvelope.getCoordinateReferenceSystem();
        if (renderingEnvelope != null  && crs instanceof GeographicCRS) {
            GeographicCRS geogCrs = (GeographicCRS) CRS.getHorizontalCRS(crs);
            CoordinateReferenceSystem horizontalSourceCrs = CRS.getHorizontalCRS(sourceCrs);
           
            ReferencedEnvelope validArea = null;
            if(horizontalSourceCrs instanceof GeographicCRS && !CRS.equalsIgnoreMetadata(horizontalSourceCrs, geogCrs)) {
                // datum shifts will create unpleasant effects if we have the poles in the mix,
                // cut them out
                if(!CRS.equalsIgnoreMetadata(horizontalSourceCrs, geogCrs)) {
                    if(CRS.getAxisOrder(sourceCrs) == AxisOrder.NORTH_EAST) {
                        validArea = new ReferencedEnvelope(MIN_LATITUDE, MAX_LATITUDE, Float.MAX_VALUE, -Float.MAX_VALUE, horizontalSourceCrs);
                    } else {
                        validArea = new ReferencedEnvelope(Float.MAX_VALUE, -Float.MAX_VALUE, MIN_LATITUDE, MAX_LATITUDE, horizontalSourceCrs);
                    }
                }
            }
           
            if(wrap && maxWraps > 0) {
                double centralMeridian = geogCrs.getDatum().getPrimeMeridian().getGreenwichLongitude();
                return new WrappingProjectionHandler(renderingEnvelope, validArea, sourceCrs, centralMeridian, maxWraps);
            } else {
                return new ProjectionHandler(sourceCrs, validArea, renderingEnvelope);
            }
        }
View Full Code Here

   * Returns a projected CRS for test purpose.
   */
  private static CoordinateReferenceSystem getProjectedCRS(
      final GridCoverage2D coverage) {
    try {
      final GeographicCRS base = (GeographicCRS) coverage.getCoordinateReferenceSystem();
      final Ellipsoid ellipsoid = base.getDatum().getEllipsoid();
      final DefaultMathTransformFactory factory = new DefaultMathTransformFactory();
      final ParameterValueGroup parameters = factory.getDefaultParameters("Oblique_Stereographic");
      parameters.parameter("semi_major").setValue(ellipsoid.getSemiMajorAxis());
      parameters.parameter("semi_minor").setValue(ellipsoid.getSemiMinorAxis());
      parameters.parameter("central_meridian").setValue(5);
View Full Code Here

   * @return
   * @throws IOException
   */
  private GeographicCRS createGeographicCoordinateReferenceSystem(
      final GeoTiffIIOMetadataDecoder metadata) throws IOException {
    GeographicCRS gcs = null;

    //
    // Get the crs code
    //
    final String tempCode = metadata.getGeoKey(GeoTiffGCSCodes.GeographicTypeGeoKey);
    // lookup the angular units used in this geotiff image
    Unit<?> angularUnit = null;
    try {
      angularUnit = createUnit(GeoTiffGCSCodes.GeogAngularUnitsGeoKey,GeoTiffGCSCodes.GeogAngularUnitSizeGeoKey, SI.RADIAN, metadata);
    } catch (GeoTiffException e) {
            if(LOGGER.isLoggable(Level.FINE)){
                LOGGER.log(Level.FINE,e.getLocalizedMessage(),e);
            }
      angularUnit = null;
    }
                if(angularUnit==null){
                    angularUnit=NonSI.DEGREE_ANGLE;
                }
               
    // linear unit
    Unit<?> linearUnit = null;
    try {
      linearUnit = createUnit(GeoTiffGCSCodes.GeogLinearUnitsGeoKey,GeoTiffGCSCodes.GeogLinearUnitSizeGeoKey, SI.METER, metadata);
    } catch (GeoTiffException e) {
                    if(LOGGER.isLoggable(Level.FINE)){
                        LOGGER.log(Level.FINE,e.getLocalizedMessage(),e);
                    }
      linearUnit = null;
    }
                if(linearUnit==null){
                    linearUnit=SI.METER;
                }   
    // if it's user defined, there's a lot of work to do
    if (tempCode == null
        || tempCode.equals(GeoTiffConstants.GTUserDefinedGeoKey_String)) {
      //
      // it is user-defined we have to parse a lot of information in order
      // to built it.
      //
      gcs = createUserDefinedGCS(metadata, linearUnit, angularUnit);

    } else {
      try {

        // ////////////////////////////////////////////////////////////////////
        //
        // If it's not user defined, just use the EPSG factory to create
        // the coordinate system but check if the user specified a
        // different angular unit. In this case we need to create a
        // user-defined GCRS.
        //
        // ////////////////////////////////////////////////////////////////////
        final StringBuilder geogCode = new StringBuilder(tempCode);
        if (!tempCode.startsWith("EPSG")
            && !tempCode.startsWith("epsg")) {
          geogCode.insert(0, "EPSG:");
        }
        gcs = (GeographicCRS) allAuthoritiesFactory.createCoordinateReferenceSystem(geogCode.toString());
        if (angularUnit != null
            && !angularUnit.equals(gcs.getCoordinateSystem()
                .getAxis(0).getUnit())) {
          // //
          //
          // Create a user-defined GCRS using the provided angular
          // unit.
          //
          // //
          gcs = new DefaultGeographicCRS(DefaultEllipsoidalCS
              .getName(gcs, new CitationImpl("EPSG")),
              (GeodeticDatum) gcs.getDatum(),
              DefaultEllipsoidalCS.GEODETIC_2D
                  .usingUnit(angularUnit));
        }
      } catch (FactoryException fe) {
        final IOException ex = new GeoTiffException(metadata, fe
View Full Code Here

    //

                //
                // GEOGRAPHIC CRS is the baseCRS for the projection
                //
                final GeographicCRS baseCRS = createGeographicCoordinateReferenceSystem(metadata);
           
    //
    // NAME of the user defined projected coordinate reference system.
    //
    String projectedCrsName = metadata.getGeoKey(GeoTiffPCSCodes.PCSCitationGeoKey);
View Full Code Here

    /**
     * Tests the CRS:84 code.
     */
    @Test
    public void testCRS84() throws FactoryException {
        GeographicCRS crs = factory.createGeographicCRS("CRS:84");
        assertSame(crs, factory.createGeographicCRS("84"));
        assertSame(crs, factory.createGeographicCRS("CRS84"));
        assertSame(crs, factory.createGeographicCRS("CRS:CRS84"));
        assertSame(crs, factory.createGeographicCRS("crs : crs84"));
        assertNotSame(crs, factory.createGeographicCRS("CRS:83"));
View Full Code Here

    /**
     * Tests the CRS:83 code.
     */
    @Test
    public void testCRS83() throws FactoryException {
        GeographicCRS crs = factory.createGeographicCRS("CRS:83");
        assertSame(crs, factory.createGeographicCRS("83"));
        assertSame(crs, factory.createGeographicCRS("CRS83"));
        assertSame(crs, factory.createGeographicCRS("CRS:CRS83"));
        assertNotSame(crs, factory.createGeographicCRS("CRS:84"));
        assertFalse(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs));
View Full Code Here

    /**
     * Tests the {@link IdentifiedObjectFinder#find} method.
     */
    @Test
    public void testFind() throws FactoryException {
        final GeographicCRS CRS84 = factory.createGeographicCRS("CRS:84");
        final IdentifiedObjectFinder finder = factory.getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
        assertTrue("Newly created finder should default to full scan.", finder.isFullScanAllowed());

        finder.setFullScanAllowed(false);
        assertSame("Should find without the need for scan, since we can use the CRS:84 identifier.",
                   CRS84, finder.find(CRS84));

        finder.setFullScanAllowed(true);
        assertSame("Allowing scanning should not make any difference for this CRS84 instance.",
                   CRS84, finder.find(CRS84));

        assertNotSame("Required condition for next test.", CRS84, DefaultGeographicCRS.WGS84);
        assertFalse  ("Required condition for next test.", CRS84.equals(DefaultGeographicCRS.WGS84));
        assertTrue   ("Required condition for next test.", CRS.equalsIgnoreMetadata(CRS84, DefaultGeographicCRS.WGS84));

        finder.setFullScanAllowed(false);
        assertNull("Should not find WGS84 without a full scan, since it doesn't contains the CRS:84 identifier.",
                   finder.find(DefaultGeographicCRS.WGS84));

        finder.setFullScanAllowed(true);
        assertSame("A full scan should allow us to find WGS84, since it is equals ignoring metadata to CRS:84.",
                   CRS84, finder.find(DefaultGeographicCRS.WGS84));

        finder.setFullScanAllowed(false);
        assertNull("The scan result should not be cached.",
                   finder.find(DefaultGeographicCRS.WGS84));

        // --------------------------------------------------
        // Same test than above, using a CRS created from WKT
        // --------------------------------------------------

        String wkt = "GEOGCS[\"WGS 84\",\n" +
                     "  DATUM[\"WGS84\",\n" +
                     "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n" +
                     "  PRIMEM[\"Greenwich\", 0.0],\n" +
                     "  UNIT[\"degree\", 0.017453292519943295]]";
        CoordinateReferenceSystem search = CRS.parseWKT(wkt);
        assertFalse("Required condition for next test.", CRS84.equals(search));
        assertTrue ("Required condition for next test.", CRS.equalsIgnoreMetadata(CRS84, search));

        finder.setFullScanAllowed(false);
        assertNull("Should not find WGS84 without a full scan, since it doesn't contains the CRS:84 identifier.",
                   finder.find(search));
View Full Code Here

     * The objects found are expected to be cached.
     */
    @Test
    public void testBufferedFind() throws FactoryException {
        final AbstractAuthorityFactory factory = new CachedCRSAuthorityDecorator(this.factory);
        final GeographicCRS CRS84 = factory.createGeographicCRS("CRS:84");
        final IdentifiedObjectFinder finder = factory.getIdentifiedObjectFinder(CoordinateReferenceSystem.class);

        finder.setFullScanAllowed(false);
        assertSame("Should find without the need for scan, since we can use the CRS:84 identifier.",
                   CRS84, finder.find(CRS84));
View Full Code Here

        parameters.parameter("standard_parallel_2").setValue(25.0);
        parameters.parameter("longitude_of_origin").setValue(-95.0);
        parameters.parameter("false_easting").setValue(0.0);
        parameters.parameter("false_northing").setValue(0.0);

        GeographicCRS base = DefaultGeographicCRS.WGS84;
        MathTransform mt   = factory.createParameterizedTransform(parameters);
        CartesianCS cs = DefaultCartesianCS.PROJECTED;
        CoordinateReferenceSystem crs = new DefaultProjectedCRS("Lambert", base, mt, cs);

        final String wkt = crs.toWKT();
View Full Code Here

TOP

Related Classes of org.opengis.referencing.crs.GeographicCRS

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.