当前位置: 首页>>代码示例>>Java>>正文


Java CRSFactory类代码示例

本文整理汇总了Java中org.opengis.referencing.crs.CRSFactory的典型用法代码示例。如果您正苦于以下问题:Java CRSFactory类的具体用法?Java CRSFactory怎么用?Java CRSFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CRSFactory类属于org.opengis.referencing.crs包,在下文中一共展示了CRSFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSRS

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
private SRS getSRS() throws KettleException {
	if (ogrLayer != null) {
		if(ogrLayer.GetSpatialRef() != null) {
			try {
				CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
				CoordinateReferenceSystem crs = crsFactory.createFromWKT(ogrLayer.GetSpatialRef().ExportToWkt());

				return new SRS(crs);
			}
			catch (FactoryException fe) {
				// TODO Do we have to do anything else here, i.e. when a FactoryException occurs while parsing the CRS WKT of the data source?
				return null;
			}
		}
		else {
			// TODO Do we have to do anything else here, i.e. when OGR SRS is set to unknown?
			return null;
		}
	}
	else {
		throw new KettleException("OGR data source is not open");
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:OGRReader.java

示例2: getCRS

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
@Override
public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters,
                                        GeodeticDatum datum) throws FactoryException {
    final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    // in some cases, depending on the parameters set, the effective transformation can be different
    // from the transformation given by the OperationMethod.
    // So we create a new one
    final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
    final MathTransform transform = mtFactory.createParameterizedTransform(parameters);
    final DefaultOperationMethod operationMethod = new DefaultOperationMethod(transform);

    final Conversion conversion = new DefiningConversion(AbstractIdentifiedObject.getProperties(operationMethod),
                                                         operationMethod, transform);

    final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>();
    baseCrsProperties.put("name", datum.getName().getCode());
    GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties,
                                                           datum,
                                                           DefaultEllipsoidalCS.GEODETIC_2D);

    final HashMap<String, Object> projProperties = new HashMap<String, Object>();
    projProperties.put("name", conversion.getName().getCode() + " / " + datum.getName().getCode());
    return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED);
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:25,代码来源:OperationMethodCrsProvider.java

示例3: createCrs

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
CoordinateReferenceSystem createCrs(String crsName, OperationMethod method,
                                              ParameterValueGroup parameters,
                                              GeodeticDatum datum) throws FactoryException {
    final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    final CoordinateOperationFactory coFactory = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
    final HashMap<String, Object> projProperties = new HashMap<String, Object>();
    projProperties.put("name", crsName + " / " + datum.getName().getCode());
    final Conversion conversion = coFactory.createDefiningConversion(projProperties,
                                                                     method,
                                                                     parameters);
    final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>();
    baseCrsProperties.put("name", datum.getName().getCode());
    final GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties, datum,
                                                                 DefaultEllipsoidalCS.GEODETIC_2D);
    return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED);
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:17,代码来源:AbstractUTMCrsProvider.java

示例4: creatCRSFromWKT

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
/**
 * An example of creating a CRS from a WKT string. Additional examples of WKT strings can be found
 * in http://svn.geotools.org/geotools/trunk/gt/module/referencing/test/org/geotools/referencing
 * /test-data/
 * 
 * @throws Exception
 */
void creatCRSFromWKT() throws Exception {
    System.out.println("------------------------------------------");
    System.out.println("Creating a CRS from a WKT string:");
    // creatCRSFromWKT start
    CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    String wkt = "PROJCS[\"UTM_Zone_10N\", " + "GEOGCS[\"WGS84\", " + "DATUM[\"WGS84\", "
            + "SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], " + "PRIMEM[\"Greenwich\", 0.0], "
            + "UNIT[\"degree\",0.017453292519943295], " + "AXIS[\"Longitude\",EAST], "
            + "AXIS[\"Latitude\",NORTH]], " + "PROJECTION[\"Transverse_Mercator\"], "
            + "PARAMETER[\"semi_major\", 6378137.0], "
            + "PARAMETER[\"semi_minor\", 6356752.314245179], "
            + "PARAMETER[\"central_meridian\", -123.0], "
            + "PARAMETER[\"latitude_of_origin\", 0.0], " + "PARAMETER[\"scale_factor\", 0.9996], "
            + "PARAMETER[\"false_easting\", 500000.0], " + "PARAMETER[\"false_northing\", 0.0], "
            + "UNIT[\"metre\",1.0], " + "AXIS[\"x\",EAST], " + "AXIS[\"y\",NORTH]]";
    
    CoordinateReferenceSystem crs = crsFactory.createFromWKT(wkt);
    // creatCRSFromWKT end
    System.out.println("  CRS: " + crs.toWKT());
    System.out.println("Identified CRS object:");
    printIdentifierStuff(crs);
    System.out.println("Identified Datum object:");
    printIdentifierStuff(((ProjectedCRS) crs).getDatum());
    System.out.println("------------------------------------------");
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:33,代码来源:ReferencingExamples.java

示例5: factories

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
void factories() {
    // factories start
    Hints hints = null; // configure hints for the group of factories
    ReferencingFactoryContainer group = new ReferencingFactoryContainer(hints);
    CRSFactory crsFactory = group.getCRSFactory();
    CSFactory csFactory = group.getCSFactory();
    DatumFactory datumFactory = group.getDatumFactory();
    // factories end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:10,代码来源:ReferencingExamples.java

示例6: createCRSByHand1

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
/**
 * Creates a WGS 84/UTM Zone 10N CRS mostly (uses some premade objects) by hand. Uses the higher
 * level FactoryGroup instead of the lower level MathTransformFactory (commented out).
 * 
 * @throws Exception
 */
void createCRSByHand1() throws Exception {
    System.out.println("------------------------------------------");
    System.out.println("Creating a CRS by hand:");
    // createCRSByHand1 start
    MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
    CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    
    GeographicCRS geoCRS = org.geotools.referencing.crs.DefaultGeographicCRS.WGS84;
    CartesianCS cartCS = org.geotools.referencing.cs.DefaultCartesianCS.GENERIC_2D;
    
    ParameterValueGroup parameters = mtFactory.getDefaultParameters("Transverse_Mercator");
    parameters.parameter("central_meridian").setValue(-111.0);
    parameters.parameter("latitude_of_origin").setValue(0.0);
    parameters.parameter("scale_factor").setValue(0.9996);
    parameters.parameter("false_easting").setValue(500000.0);
    parameters.parameter("false_northing").setValue(0.0);
    Conversion conversion = new DefiningConversion("Transverse_Mercator", parameters);
    
    Map<String, ?> properties = Collections.singletonMap("name", "WGS 84 / UTM Zone 12N");
    ProjectedCRS projCRS = crsFactory.createProjectedCRS(properties, geoCRS, conversion, cartCS);
    // createCRSByHand1 end
    
    // parameters.parameter("semi_major").setValue(((GeodeticDatum)geoCRS.getDatum()).getEllipsoid().getSemiMajorAxis());
    // parameters.parameter("semi_minor").setValue(((GeodeticDatum)geoCRS.getDatum()).getEllipsoid().getSemiMinorAxis());
    
    // MathTransform trans = mtFactory.createParameterizedTransform(parameters);
    // ProjectedCRS projCRS = crsFactory.createProjectedCRS(
    // Collections.singletonMap("name", "WGS 84 / UTM Zone 12N"),
    // new org.geotools.referencing.operation.OperationMethod(trans),
    // geoCRS, trans, cartCS);
    System.out.println("  Projected CRS: " + projCRS.toWKT());
    System.out.println("------------------------------------------");
    
    // save for later use in createMathTransformBetweenCRSs()
    this.utm10NCRS = projCRS;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:43,代码来源:ReferencingExamples.java

示例7: createCRSByHand2

import org.opengis.referencing.crs.CRSFactory; //导入依赖的package包/类
/**
 * Creates a NAD 27 geographic CRS. Notice that the datum factory automatically adds aliase names to
 * the datum (because "North American Datum 1927" has an entry in http://svn.geotools.org
 * /geotools/trunk/gt/module/referencing/src/org/geotools/referencing/factory /DatumAliasesTable.txt
 * ). Also notice that toWGS84 information (used in a datum transform) was also added to the datum.
 */
void createCRSByHand2() throws Exception {
    System.out.println("------------------------------------------");
    System.out.println("Creating a CRS by hand:");
    // createCRSByHand2 start
    CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    DatumFactory datumFactory = ReferencingFactoryFinder.getDatumFactory(null);
    CSFactory csFactory = ReferencingFactoryFinder.getCSFactory(null);
    
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "Clarke 1866");
    
    Ellipsoid clark1866ellipse = datumFactory.createFlattenedSphere(map, 6378206.4,
            294.978698213901, SI.METER);
    
    PrimeMeridian greenwichMeridian = org.geotools.referencing.datum.DefaultPrimeMeridian.GREENWICH;
    
    final BursaWolfParameters toWGS84 = new BursaWolfParameters(DefaultGeodeticDatum.WGS84);
    toWGS84.dx = -3.0;
    toWGS84.dy = 142;
    toWGS84.dz = 183;
    
    map.clear();
    map.put("name", "North American Datum 1927");
    map.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, toWGS84);
    
    GeodeticDatum clark1866datum = datumFactory.createGeodeticDatum(map, clark1866ellipse,
            greenwichMeridian);
    System.out.println(clark1866datum.toWKT());
    // notice all of the lovely datum aliases (used to determine if two
    // datums are the same)
    System.out.println("Identified Datum object:");
    printIdentifierStuff(clark1866datum);
    
    map.clear();
    map.put("name", "<lat>, <long>");
    CoordinateSystemAxis latAxis = org.geotools.referencing.cs.DefaultCoordinateSystemAxis.GEODETIC_LATITUDE;
    CoordinateSystemAxis longAxis = org.geotools.referencing.cs.DefaultCoordinateSystemAxis.GEODETIC_LONGITUDE;
    EllipsoidalCS ellipsCS = csFactory.createEllipsoidalCS(map, latAxis, longAxis);
    
    map.clear();
    map.put("name", "NAD 27");
    map.put("authority", "9999");
    // TODO add an authority code here (should be an identifier)
    GeographicCRS nad27CRS = crsFactory.createGeographicCRS(map, clark1866datum, ellipsCS);
    // createCRSByHand2 end
    System.out.println(nad27CRS.toWKT());
    System.out.println("Identified CRS object:");
    printIdentifierStuff(nad27CRS);
    
    System.out.println("------------------------------------------");
    
    // save for latter use in createMathTransformBetweenCRSs()
    this.nad27CRS = nad27CRS;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:61,代码来源:ReferencingExamples.java


注:本文中的org.opengis.referencing.crs.CRSFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。