Package org.opengis.referencing.crs

Examples of org.opengis.referencing.crs.GeographicCRS


      int dim = crs.getCoordinateSystem().getDimension();
      boolean isProjectedCRS = crs instanceof ProjectedCRS;
      CoordinateReferenceSystem bcrs = crs instanceof ProjectedCRS
      ? ((ProjectedCRS) crs).getBaseCRS() : crs;
     
  GeographicCRS wgs84crs = null;
        try {
                wgs84crs = (GeographicCRS) CRS.decode("EPSG:4327");
        } catch (Exception nsace){
                getLog().warn("could not get crs for EPSG:4327");
        }
     
        //have doubts about following line, was the commented out 2nd clause to condition doing anything - colin      
        if (bcrs.equals(wgs84crs)) {    // || bcrs.equals(CRSUtils.WGS84_PROJ)) {
        return dp;
      }
        //again, what does the follllowing achieve? - colin
      if (bcrs.toWKT().indexOf("WGS84") > -1) {
        return dp;
      }
      if (bcrs instanceof GeographicCRS) {
        if (((GeographicCRS) bcrs).getDatum().equals(wgs84crs.getDatum())) {
          return dp;
        }
      }
        //not going to need CommonFactory.getCoordinateOperationFactory(),
        //can use transform util in org.geotools.referencing.CRS instaed
View Full Code Here


                        datum = createGeodeticDatum(dmCode);
                    } else {
                        final String geoCode = getString(result, 9, code, 8);
                        result.close(); // Must be close before createGeographicCRS
                        result = null;
                        final GeographicCRS baseCRS = createGeographicCRS(geoCode);
                        datum = baseCRS.getDatum();
                    }
                    final Map<String,Object> properties = generateProperties(name, epsg, area, scope, remarks);
                    crs = factory.createGeographicCRS(properties, datum, cs);
                }
                /* ----------------------------------------------------------------------
                 *   PROJECTED CRS
                 *
                 *   NOTE: This method invokes itself indirectly, through createGeographicCRS.
                 *         Consequently, we can't use 'result' anymore. We must close it here.
                 * ---------------------------------------------------------------------- */
                else if (type.equalsIgnoreCase("projected")) {
                    final String csCode  = getString(result,  7, code);
                    final String geoCode = getString(result,  9, code);
                    final String opCode  = getString(result, 10, code);
                    result.close(); // Must be close before createGeographicCRS
                    result = null;
                    final CartesianCS         cs = createCartesianCS(csCode);
                    final GeographicCRS  baseCRS = createGeographicCRS(geoCode);
                    final CoordinateOperation op = createCoordinateOperation(opCode);
                    if (op instanceof Conversion) {
                        final Map<String,Object> properties = generateProperties(name, epsg, area, scope, remarks);
                        crs = factory.createProjectedCRS(properties, baseCRS, (Conversion)op, cs);
                    } else {
View Full Code Here

            return new DefaultGeographicCRS("Geodetic", (GeodeticDatum) datum,
                    DefaultEllipsoidalCS.GEODETIC_2D);
        }
        if (crs instanceof CompoundCRS) {
            for (final CoordinateReferenceSystem component : ((CompoundCRS) crs).getCoordinateReferenceSystems()) {
                final GeographicCRS candidate = getGeographicCRS(component);
                if (candidate != null) {
                    return candidate;
                }
            }
        }
View Full Code Here

  }

  public GeographicCRS createGeographicCRS(String code)
      throws FactoryException {
    final String key = toKey(code);
    GeographicCRS crs = (GeographicCRS) cache.get(key);
    if (crs == null) {
      try {
        cache.writeLock(key);
        crs = (GeographicCRS) cache.peek(key);
        if (crs == null) {
View Full Code Here

    public static void copy(Envelope envelope, final GeographicBoundingBoxImpl box)
            throws TransformException
    {
        final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
        if (crs != null) {
            final GeographicCRS standardCRS = CRSUtilities.getStandardGeographicCRS2D(crs);
            if (!startsWith(crs, standardCRS) &&
                !startsWith(crs, DefaultGeographicCRS.WGS84) &&
                !startsWith(crs, DefaultGeographicCRS.WGS84_3D))
            {
                final CoordinateOperation operation;
View Full Code Here

     */
    public static GeographicCRS getBaseCRS(final double equatorialRadius,
            final double inverseFlattening) {
        final DefaultGeodeticDatum datum = Utilities.getDefaultGeodeticDatum("WGS84",
                equatorialRadius, inverseFlattening, SI.METER);
        final GeographicCRS sourceCRS = new DefaultGeographicCRS("WGS-84", datum,
                DefaultGeographicCRS.WGS84.getCoordinateSystem());
        return sourceCRS;
    }
View Full Code Here

   * @return
   * @throws IOException
   */
  private GeographicCRS createGeographicCoordinateSystem(
      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,
          NonSI.DEGREE_ANGLE, metadata);
    } catch (GeoTiffException e) {
      angularUnit = null;
    }
    // linear unit
    Unit linearUnit = null;
    try {
      linearUnit = createUnit(GeoTiffGCSCodes.GeogLinearUnitsGeoKey,
          GeoTiffGCSCodes.GeogLinearUnitSizeGeoKey, SI.METER,
          SI.METER, metadata);
    } catch (GeoTiffException e) {
      linearUnit = null;
    }
    // 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 StringBuffer geogCode = new StringBuffer(tempCode);
        if (!tempCode.startsWith("EPSG")
            && !tempCode.startsWith("epsg")) {
          geogCode.insert(0, "EPSG:");
        }
        gcs = (GeographicCRS) CRS.decode(geogCode.toString(), true);
        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
    //
    // /////////////////////////////////////////////////////////////////////
    final GeographicCRS gcs = createGeographicCoordinateSystem(metadata);

    // was the projection user defined?
    // in such case we need to set the remaining parameters.
    if (projUserDefined) {
      final GeodeticDatum tempDatum = ((GeodeticDatum) gcs.getDatum());
      final DefaultEllipsoid tempEll = (DefaultEllipsoid) tempDatum
          .getEllipsoid();
      double inverseFlattening = tempEll.getInverseFlattening();
      double semiMajorAxis = tempEll.getSemiMajorAxis();
      // setting missing parameters
View Full Code Here

    // lookup the Geodetic datum
    final GeodeticDatum datum = createGeodeticDatum(linearUnit, metadata);

    // coordinate reference system
    GeographicCRS gcs = null;

    try {
      // property map is reused
      final Map props = new HashMap();
      // make the user defined GCS from all the components...
View Full Code Here

     * Tests geodetic calculator involving a coordinate operation.
     * Our test uses a simple geographic CRS with only the axis order interchanged.
     */
    @Test
    public void testUsingTransform() throws FactoryException, TransformException {
        final GeographicCRS crs = new DefaultGeographicCRS("Test", DefaultGeodeticDatum.WGS84,
                new DefaultEllipsoidalCS("Test", DefaultCoordinateSystemAxis.LATITUDE,
                                                 DefaultCoordinateSystemAxis.LONGITUDE));
        final GeodeticCalculator calculator = new GeodeticCalculator(crs);
        assertSame(crs, calculator.getCoordinateReferenceSystem());

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.