当前位置: 首页>>代码示例>>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;未经允许,请勿转载。