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


Java ReferencingFactoryFinder类代码示例

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


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

示例1: createFeatureType

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
 * Create the schema for your FeatureType cq shapefile
 */
private static SimpleFeatureType createFeatureType() {

    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName("GeometryError");
    
    try {
    	CRSAuthorityFactory authorityFactory = ReferencingFactoryFinder.getCRSAuthorityFactory("epsg", null);
    	builder.setCRS(authorityFactory.createCoordinateReferenceSystem("28992")); // <- Coordinate reference system
    } catch(Exception e) {
    	throw new RuntimeException(e);
    }

    // add attributes
    builder.add("Location", Point.class);
    builder.add("InspireId", String.class);
    builder.add("Message", String.class);

    return builder.buildFeatureType();
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:23,代码来源:FeatureCollectionFactory.java

示例2: getSRS

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的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

示例3: getCRS

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的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

示例4: createCrs

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的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

示例5: createDatumSet

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static Set<GeodeticDatum> createDatumSet() {
    DatumAuthorityFactory factory = ReferencingFactoryFinder.getDatumAuthorityFactory("EPSG", null);
    List<String> datumCodes = retrieveCodes(GeodeticDatum.class, factory);
    Set<GeodeticDatum> datumSet = new TreeSet<>(AbstractIdentifiedObject.NAME_COMPARATOR);
    for (String datumCode : datumCodes) {
        try {
            DefaultGeodeticDatum geodeticDatum = (DefaultGeodeticDatum) factory.createGeodeticDatum(datumCode);
            if (geodeticDatum.getBursaWolfParameters().length != 0 ||
                    DefaultGeodeticDatum.isWGS84(geodeticDatum)) {
                datumSet.add(geodeticDatum);
            }
        } catch (FactoryException ignored) {
        }
    }
    return datumSet;
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:17,代码来源:CustomCrsPanel.java

示例6: convertUTM_MGA942Geographic_EPSG4326

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static Geometry convertUTM_MGA942Geographic_EPSG4326(Double easting, Double northing, String zone) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException, TransformException{
	CoordinateReferenceSystem geographic = CRS.decode("EPSG:4326", false);
	CoordinateReferenceSystem geographic2 = ReferencingFactoryFinder.getCRSAuthorityFactory(
			"EPSG", null).createCoordinateReferenceSystem("4326");
	

	
	CoordinateReferenceSystem utm = ReferencingFactoryFinder.getCRSAuthorityFactory(
			"EPSG", null).createCoordinateReferenceSystem("283"+zone);
	
	CoordinateOperationFactory coFactory = ReferencingFactoryFinder
			.getCoordinateOperationFactory(null);
	
	CoordinateReferenceSystem sourceCRS = utm;		
	CoordinateReferenceSystem targetCRS = geographic;

	GeometryFactory gf = new GeometryFactory();
       Coordinate coord = new Coordinate( easting, northing );
       Point point = gf.createPoint( coord );
       
	
	MathTransform mathTransform =CRS.findMathTransform( sourceCRS, targetCRS,true );
	Geometry g2 = JTS.transform(point, mathTransform);
	
	//VT: Flip around to correct the lat lon from the utm to geographic transformation
	Coordinate[] original = g2.getCoordinates();
	for(int i = 0; i < original.length; i++){
	    Double swapValue = original[i].x;
	    original[i].x = original[i].y;
	    original[i].y = swapValue;
	}
    
	return g2;
}
 
开发者ID:AuScope,项目名称:igsn30,代码行数:35,代码来源:SpatialUtilities.java

示例7: filterCRSNames

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
 * filters all CRS Names from all available CRS authorities
 * 
 * @param filter
 *            array of keywords
 * @return Set of CRS Names which contain all the filter keywords
 */
protected Set<String> filterCRSNames(final String[] filter) {
	crsCodeMap = new HashMap<String, String>();
	final Set<String> descriptions = new TreeSet<String>();

	for (final Object object : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) {
		final CRSAuthorityFactory factory = (CRSAuthorityFactory) object;
		try {
			final Set<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
			for (final Object codeObj : codes) {
				final String code = (String) codeObj;
				String description;
				try {
					description = factory.getDescriptionText(code).toString();
				} catch (final Exception e1) {
					description = "UNNAMED";
				}
				description += " (" + code + ")"; //$NON-NLS-1$ //$NON-NLS-2$
				crsCodeMap.put(code, description);
				if (matchesFilter(description.toUpperCase(), filter)) {
					descriptions.add(description);
				}
			}
		} catch (final FactoryException e) {
			ExceptionMonitor.show(wktText.getShell(), e, "CRS Authority:" + e.getMessage());
		}
	}
	return descriptions;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:36,代码来源:CRSChooser.java

示例8: getAllSRSCodes

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
 * @return A plain array with all EPSG-codes.
 */
public static String[] getAllSRSCodes() {
	CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory(SRS.AUTH_EPSG, null);
	try {
		Set<String> srids = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
		String[] epsg_codes = new String[srids.size()];
		return srids.toArray(epsg_codes);
	} catch (FactoryException e) {
		return null;
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:14,代码来源:SRSList.java

示例9: createComboSelectionSRS

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
 * Creates the SRS from the selected SRID
 * 
 * @param srid The srid from the selected Entry in Combo
 */
private void createComboSelectionSRS(String srid) {
	String authority_epsg = Citations.getIdentifier(Citations.EPSG);
	CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory(authority_epsg, null);
	try {
		if(srid == ""){
			selectedSRS = SRS.UNKNOWN;
		}else{
			selectedSRS = new SRS(authority_epsg, srid, factory.getDescriptionText(srid).toString());						
		}
	} catch (Exception ex) {
		selectedSRS = new SRS("GeoKettle", srid, "Custom");
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:19,代码来源:SetSRSDialog.java

示例10: createCRS

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public CoordinateReferenceSystem createCRS(String crsWkt){
	CoordinateReferenceSystem crs;	
	try {
		crs = ReferencingFactoryFinder.getCRSFactory(null).createFromWKT(crsWkt);
		return crs;
	}catch (FactoryException exception) {
		exception.printStackTrace();
		return null;
	}		
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:11,代码来源:LayerFactory.java

示例11: getProperties

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
 * Fills a {@link SRSInit} object with the correct initialization values
 * needed by constructors (authority, description, srid).
 * 
 * Note: The method tries to retrieve as much information from the
 * {@link CoordinateReferenceSystem} <code>crs</code> as possible.
 * 
 * @param init Pass the {@link SRSInit} object to allow multiple return-values.
 * @param crs The {@link CoordinateReferenceSystem} where the information
 *            are retrieved from.
 */
private void getProperties(SRSInit init, CoordinateReferenceSystem crs) {
	// Try to find srid, authority and description from the CRS.
	// Abort if the correct EPSG identifiers were found.
	Set<ReferenceIdentifier> identifiers = crs.getIdentifiers();
	if (!identifiers.isEmpty()) {
		for (ReferenceIdentifier id : identifiers) {
			init.auth = Citations.getIdentifier(id.getAuthority());
			init.srid = id.getCode();
			try {					
				CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory(init.auth, HINTS);
				init.desc = factory.getDescriptionText(init.srid).toString();
				this.is_custom = false;
				break;
			} catch (Exception e) {
				this.is_custom = true;
			}
		}
	} else 
		this.is_custom = true;		

	// If this is not an EPSG spatial reference system, use WKT to describe it but get
	// as much information as possible about the SRS from the WKT.
	if (this.is_custom) {
		init.srid = Const.NVL(init.srid, Integer.toString(UNKNOWN_SRID));
		init.auth = Const.NVL(init.auth, "Custom Authority");
		init.desc = Const.NVL(init.desc, "Custom SRS from WKT");
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:40,代码来源:SRS.java

示例12: createCrsProviderSet

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static Set<AbstractCrsProvider> createCrsProviderSet() {
    MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
    Set<OperationMethod> methods = factory.getAvailableMethods(Projection.class);

    TreeSet<AbstractCrsProvider> crsProviderSet = new TreeSet<>(new CrsProviderComparator());
    for (OperationMethod method : methods) {
        crsProviderSet.add(new OperationMethodCrsProvider(method));
    }

    return crsProviderSet;
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:12,代码来源:CustomCrsPanel.java

示例13: GridTransforms

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public GridTransforms(String espgCode) {
	Spatial.initSpatial();
	try {
		crsFac = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);
		wgs84crs = crsFac.createCoordinateReferenceSystem("4326");
		gridcrs = crsFac.createCoordinateReferenceSystem(espgCode);
		latLongToGrid = new DefaultCoordinateOperationFactory().createOperation(wgs84crs, gridcrs);
		gridToLongLat = new DefaultCoordinateOperationFactory().createOperation(gridcrs, wgs84crs);			
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:14,代码来源:GridTransforms.java

示例14: initSpatial

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static synchronized void initSpatial(){
	if(!init){
		// ensure geotools uses longitude, latitude order, not latitude, longitude, in the entire application
		System.setProperty("org.geotools.referencing.forceXY", "true");
		crsFac = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);		
		try {
			wgs84crs = crsFac.createCoordinateReferenceSystem("4326");	
			

		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:15,代码来源:Spatial.java

示例15: transfGeom

import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
 * Returns a geometry based on the transformation from a source geometry CRS
 * to a defined target CRS.
 *
 */
private Geometry transfGeom(Geometry g, CoordinateReferenceSystem outputCRS) throws TransformException, NoSuchAuthorityCodeException, FactoryException {

    Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
    CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints);
    CoordinateReferenceSystem srcCRS = factory.createCoordinateReferenceSystem("EPSG:4326");

    outputCRS = factory.createCoordinateReferenceSystem("EPSG:900913");

    MathTransform transform;
    transform = CRS.findMathTransform(srcCRS, outputCRS, false);
    Geometry trgGeom = JTS.transform(g, transform);

    return trgGeom;
}
 
开发者ID:geobeyond,项目名称:fluxomajic,代码行数:20,代码来源:FluxoFilterFunction.java


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