當前位置: 首頁>>代碼示例>>Java>>正文


Java CRS.decode方法代碼示例

本文整理匯總了Java中org.geotools.referencing.CRS.decode方法的典型用法代碼示例。如果您正苦於以下問題:Java CRS.decode方法的具體用法?Java CRS.decode怎麽用?Java CRS.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.geotools.referencing.CRS的用法示例。


在下文中一共展示了CRS.decode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
@Override
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    Envelope envelope = (Envelope) super.parse(instance, node, value);

    // handle the box CRS
    CoordinateReferenceSystem crs = this.crs;
    if (node.hasAttribute("srsName")) {
        URI srs = (URI) node.getAttributeValue("srsName");
        crs = CRS.decode(srs.toString());
    }
    
    if(crs != null) {
        return ReferencedEnvelope.create(envelope, crs);
    } else {
        return envelope;
    }
}
 
開發者ID:STEMLab,項目名稱:geoserver-3d-extension,代碼行數:18,代碼來源:GMLBoxTypeBinding_ISO.java

示例2: getPixelFromGeo

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * Computes the subpixel (i.e. precision greater than integer) location of a map coordinates
 * @param xgeo is the longitude
 * @param ygeo is the latitude
 * @param inputEpsgProjection is the projection system of (xgeo, ygeo) (for instance "EPSG:4326"). if null use the original projection
 * @return [xpixel, ypixel]
 *
 */
public double[] getPixelFromGeo(double xgeo, double ygeo, String inputEpsgProjection) {
	double[] out = new double[]{xgeo, ygeo};
    if (inputEpsgProjection != null) {
        try {
            double[] temp = new double[]{xgeo, ygeo, 0};
            CoordinateReferenceSystem crs = CRS.decode(inputEpsgProjection);
            MathTransform math = CRS.findMathTransform(crs, sourceCRS);
            math.transform(temp, 0, temp, 0, 1);
            out[0] = temp[0];
            out[1] = temp[1];
        } catch (Exception ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    geo2pix.transform(out, 0, out, 0, 1);
    out[0] = out[0];
    out[1] = out[1];
    return out;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:28,代碼來源:GcpsGeoTransform.java

示例3: getGeoFromPixel

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
   * Computes the map coordinates given the pixel location in the image reference
   * @param xpix the pixel location in x
   * @param ypix the pixel location in y
   * @param outputEpsgProjection is the projection system of the result (for instance "EPSG:4326")  if null use the original projection
   * @return [longitude, latitude]
   * 
   * 
   */
  public double[] getGeoFromPixel(double xpix, double ypix, String outputEpsgProjection) {
  	double[] out = new double[2];
pix2geo.transform(new double[]{xpix , ypix }, 0, out, 0, 1);
      //pix2geo.transform(new double[]{xpix + m_translationX, ypix + m_translationY}, 0, out, 0, 1);
      if (outputEpsgProjection != null) {
          try {
              double[] temp = new double[3];
              CoordinateReferenceSystem crs = CRS.decode(outputEpsgProjection);
              MathTransform math = CRS.findMathTransform(sourceCRS, crs);
              math.transform(new double[]{out[0], out[1], 0}, 0, temp, 0, 1);
              out[0] = temp[0];
              out[1] = temp[1];
          } catch (Exception ex) {
          	logger.error(ex.getMessage(),ex);
          }
      }
      return out;
  }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:28,代碼來源:GcpsGeoTransform.java

示例4: getPixelFromGeo

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * 
 */
public double[] getPixelFromGeo(double xgeo, double ygeo, String inputEpsgProjection) {
    double[] out = new double[]{xgeo, ygeo};
    if (inputEpsgProjection != null) {
        try {
            double[] temp = new double[]{xgeo, ygeo, 0};
            CoordinateReferenceSystem crs = CRS.decode(inputEpsgProjection);
            MathTransform math = CRS.findMathTransform(crs, sourceCRS);
            math.transform(temp, 0, temp, 0, 1);
            out[0] = temp[0];
            out[1] = temp[1];
        } catch (Exception ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    geo2pix.transform(out, 0, out, 0, 1);
    return out;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:21,代碼來源:AffineGeoTransform.java

示例5: getGeoFromPixel

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
public double[] getGeoFromPixel(double xpix, double ypix, String outputEpsgProjection) {
    double[] out = new double[2];
    pix2geo.transform(new double[]{xpix, ypix}, 0, out, 0, 1);
    if (outputEpsgProjection != null) {
        try {
            double[] temp = new double[3];
            CoordinateReferenceSystem crs = CRS.decode(outputEpsgProjection);
            MathTransform math = CRS.findMathTransform(sourceCRS, crs);
            math.transform(new double[]{out[0], out[1], 0}, 0, temp, 0, 1);
            out[0] = temp[0];
            out[1] = temp[1];
        } catch (Exception ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    return out;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:18,代碼來源:AffineGeoTransform.java

示例6: getDeclaredCrs

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * Returns the declared CRS given the native CRS and the request WFS version
 * 
 * @param nativeCRS
 * @param wfsVersion
 *
 */
public static CoordinateReferenceSystem getDeclaredCrs(CoordinateReferenceSystem nativeCRS,
        String wfsVersion) {
    try {
        if(nativeCRS == null)
            return null;
        
        if (wfsVersion.equals("1.0.0")) {
            return nativeCRS;
        } else {
            String code = GML2EncodingUtils.epsgCode(nativeCRS);
            //it's possible that we can't do the CRS -> code -> CRS conversion...so we'll just return what we have
            if (code == null) return nativeCRS;
            return CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:" + code);
        }
    } catch (Exception e) {
        throw new WFSException("We have had issues trying to flip axis of " + nativeCRS, e);
    }
}
 
開發者ID:STEMLab,項目名稱:geoserver-3d-extension,代碼行數:26,代碼來源:WFSReprojectionUtil_ISO.java

示例7: compareCarteRecale

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * 
 * @param reseauRecale1
 * @param reseauRecale2
 * @throws Exception
 */
private void compareCarteRecale(CarteTopo reseauRecale1,  CarteTopo reseauRecale2) throws Exception {

    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
    
    GML encode = new GML(Version.WFS1_0);
    encode.setNamespace("geotools", "http://geotools.org");
    
    // Arcs recales du reseau 1
    SimpleFeatureCollection arcs1 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale1.getPopArcs(), sourceCRS);
    ByteArrayOutputStream output1 = new ByteArrayOutputStream();
    encode.encode(output1, arcs1);
    
    // Arcs recales du reseau 2
    SimpleFeatureCollection arcs2 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale2.getPopArcs(), sourceCRS);
    ByteArrayOutputStream output2 = new ByteArrayOutputStream();
    encode.encode(output2, arcs2);
    
    // On compare : est-ce que le XML est comparable ????
    assertXMLEqual(output1.toString(), output2.toString());
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:27,代碼來源:ITRecalageAppariement.java

示例8: decode

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * Decodes a given code to a {@link org.opengis.referencing.crs.CompoundCRS}
 * @param code the code
 * @return the compound CRS
 * @throws FactoryException if the code does not represent a compound CRS
 * or if one of its components could not be decoded
 */
public static CoordinateReferenceSystem decode(String code) throws FactoryException {
  code = code.trim();
  if (!isCompound(code)) {
    throw new NoSuchAuthorityCodeException("No compound CRS", AUTHORITY, code);
  }
  
  code = code.substring(PREFIX.length());
  String[] parts = code.split(",");
  CoordinateReferenceSystem[] crss = new CoordinateReferenceSystem[parts.length];
  for (int i = 0; i < crss.length; ++i) {
    crss[i] = CRS.decode(AUTHORITY + ":" + parts[i].trim());
  }
  
  return new DefaultCompoundCRS("", crss);
}
 
開發者ID:georocket,項目名稱:georocket,代碼行數:23,代碼來源:CompoundCRSDecoder.java

示例9: setExtend

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
private void setExtend(Double x1, Double x2, Double y1, Double y2, String
        crs) {
    CoordinateReferenceSystem coordinateReferenceSystem = null;
    try {
        coordinateReferenceSystem = CRS.decode(crs);
        ReferencedEnvelope initExtend =
                new ReferencedEnvelope(x1,
                        x2,
                        y1,
                        y2, coordinateReferenceSystem);
        setExtend(initExtend);
    } catch (FactoryException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
    }

}
 
開發者ID:gdi-by,項目名稱:downloadclient,代碼行數:17,代碼來源:WMSMapSwing.java

示例10: MrGeoReader

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
MrGeoReader(Properties config) throws IOException
{
  this.config = config;

  String epsg = "EPSG:4326";
  try
  {
    epsg4326 = CRS.decode(epsg);
  }
  catch (FactoryException e)
  {
    e.printStackTrace();
  }


  providerProperties = new ProviderProperties(config.getProperty(USERNAME, ""), config.getProperty(USER_ROLES, ""));

  loadLayers();

}
 
開發者ID:ngageoint,項目名稱:mrgeo-geoserver-plugin,代碼行數:21,代碼來源:MrGeoReader.java

示例11: CRSTransform

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * CRS transform.
 *
 * @param sourceEpsgCRSCode the source epsg CRS code
 * @param targetEpsgCRSCode the target epsg CRS code
 * @return true, if successful
 */
public boolean CRSTransform(String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
	try {
   	CoordinateReferenceSystem sourceCRS = CRS.decode(sourceEpsgCRSCode);
	CoordinateReferenceSystem targetCRS = CRS.decode(targetEpsgCRSCode);
	final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false);
	this.CRStransformation=true;
	this.sourceEpsgCode=sourceEpsgCRSCode;
	this.targetEpgsgCode=targetEpsgCRSCode;
	this.rawSpatialRDD = this.rawSpatialRDD.map(new Function<T,T>()
	{
		@Override
		public T call(T originalObject) throws Exception {
			return (T) JTS.transform(originalObject,transform);
		}
	});
	return true;
	} catch (FactoryException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return false;
	}
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:31,代碼來源:SpatialRDD.java

示例12: reprojectBounds

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
public static Bounds reprojectBounds(Bounds inBounds, String fromCRS, String toCRS) {
	if (fromCRS.equals(toCRS))
		return inBounds;

	try {
		double ulx = inBounds.getLeft();
		double uly = inBounds.getTop();
		double lrx = inBounds.getRight();
		double lry = inBounds.getBottom();

		CoordinateReferenceSystem sourceCRS = CRS.decode(fromCRS);
		CoordinateReferenceSystem targetCRS = CRS.decode(toCRS);
		if (CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
			return inBounds;
		} else {
			ReferencedEnvelope re = new ReferencedEnvelope(ulx, lrx, lry, uly, sourceCRS);
			BoundingBox b = re.toBounds(targetCRS);
			return getBounds(b);
		}
	} catch (Exception e) {
	}

	return null;
}
 
開發者ID:lizardtechblog,項目名稱:ExpressZip,代碼行數:25,代碼來源:MapModel.java

示例13: decodeCRS

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
public static CoordinateReferenceSystem decodeCRS(
		String crsCode ) {

	CoordinateReferenceSystem crs = null;
	try {
		crs = CRS.decode(
				crsCode,
				true);
	}
	catch (final FactoryException e) {
		LOGGER.error(
				"Unable to decode '" + crsCode + "' CRS",
				e);
		throw new RuntimeException(
				"Unable to decode '" + crsCode + "' CRS",
				e);
	}

	return crs;

}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:22,代碼來源:SpatialTemporalDimensionalityTypeProvider.java

示例14: testImportBuildings

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
/**
 * Try to re-import buildings as another layer (different name, different projection)
 */
@Test
public void testImportBuildings() throws Exception {
    FeatureTypeInfo ti = getCatalog()
            .getFeatureTypeByName(getLayerId(SystemTestData.BUILDINGS));
    SimpleFeatureCollection rawSource = (SimpleFeatureCollection) ti.getFeatureSource(null,
            null).getFeatures();
    ForceCoordinateSystemFeatureResults forced = new ForceCoordinateSystemFeatureResults(
            rawSource, CRS.decode("EPSG:4326"));

    ImportProcess importer = new ImportProcess(getCatalog());
    String result = importer.execute(forced, null, SystemTestData.CITE_PREFIX,
            SystemTestData.CITE_PREFIX, "Buildings2", null, null, null);

    checkBuildings2(result);
}
 
開發者ID:geosolutions-it,項目名稱:soil_sealing,代碼行數:19,代碼來源:ImportProcessTest.java

示例15: main

import org.geotools.referencing.CRS; //導入方法依賴的package包/類
public static void main(String[] args) throws MalformedURLException,
		IOException, NoSuchAuthorityCodeException, FactoryException {
	if (args.length < 3) {
		System.err.println("Usage: ReprojectShapeFile in.shp out.shp epsg:code");
		System.exit(3);
	}
	File in = new File(args[0]);
	File out = new File(args[1]);
	CoordinateReferenceSystem crs = CRS.decode(args[2]);

	ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
	FileDataStore inStore = fac.createDataStore(in.toURI().toURL());
	FileDataStore outStore = fac.createDataStore(out.toURI().toURL());

	SimpleFeatureCollection inFeatures = inStore.getFeatureSource()
			.getFeatures();

	ReprojectShapeFile reprojector = new ReprojectShapeFile();

	SimpleFeatureCollection outFeatures = reprojector
			.reproject(inFeatures, crs);
	outStore.createSchema(outFeatures.getSchema());
	Transaction transaction = new DefaultTransaction("create");
	String outName = outStore.getNames().get(0).getLocalPart();
	SimpleFeatureSource featureSource = outStore.getFeatureSource(outName);
	FeatureStore featureStore = (FeatureStore) featureSource;
	featureStore.setTransaction(transaction);
	featureStore.addFeatures(outFeatures);
	transaction.commit();
	outStore.dispose();
}
 
開發者ID:ianturton,項目名稱:geotools-cookbook,代碼行數:32,代碼來源:ReprojectShapeFile.java


注:本文中的org.geotools.referencing.CRS.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。