本文整理汇总了Java中org.opengis.referencing.FactoryException类的典型用法代码示例。如果您正苦于以下问题:Java FactoryException类的具体用法?Java FactoryException怎么用?Java FactoryException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FactoryException类属于org.opengis.referencing包,在下文中一共展示了FactoryException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setExtend
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
/**
* sets the viewport of the map to the given extend.
*
* @param envelope the extend
*/
public void setExtend(ReferencedEnvelope envelope) {
try {
envelope = envelope.transform(this.mapContent.getViewport()
.getCoordinateReferenceSystem(), true);
double xLength = envelope.getSpan(0);
xLength = xLength * TEN_PERCENT;
double yLength = envelope.getSpan(1);
yLength = yLength * TEN_PERCENT;
envelope.expandBy(xLength, yLength);
bboxAction.resetCoordinates();
mapPane.deleteGraphics();
mapPane.setDisplayArea(envelope);
} catch (FactoryException | TransformException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
}
示例2: merge
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
private Optional<ReferencedEnvelope> merge(final ReferencedEnvelope oldEnv,
final Collection<ReferencedEnvelope> dirtyList) {
final CoordinateReferenceSystem declaredCrs = oldEnv.getCoordinateReferenceSystem();
return dirtyList.stream()
.map(env->{
if(env instanceof ReferencedEnvelope3D) {
return new ReferencedEnvelope(env, CRS.getHorizontalCRS(env.getCoordinateReferenceSystem()));
} else {
return env;
}
})
.map(env->{
try {
return env.transform(declaredCrs, true, 1000);
} catch (TransformException | FactoryException e) {
throw new RuntimeException("Error while merging bounding boxes",e);
}
})
.reduce((env1, env2)->{ReferencedEnvelope x = new ReferencedEnvelope(env1); x.expandToInclude(env2); return x;});
}
示例3: toShapeFile
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
/**
* write a shapefile representing the grid in a coordinate ref system ex :
* "EPSG:2975" -> RGR92, "EPSG:2154" -> L93, "EPSG:4326" -> WGS84
*
* @param fileName
* @param epsg
*/
public void toShapeFile(String fileName, String epsg) {
FT_FeatureCollection<IFeature> pop = new FT_FeatureCollection<>();
System.out.println("writing..." + fileName);
for (int i = 0; i < nbRows(); ++i)
for (int j = 0; j < nbCols(); ++j)
pop.add(new DefaultFeature(tiles[i][j]));
CRSAuthorityFactory factory = CRS.getAuthorityFactory(true);
CoordinateReferenceSystem crs = null;
try {
crs = factory.createCoordinateReferenceSystem(epsg);
} catch (FactoryException e) {
e.printStackTrace();
}
ShapefileWriter.write(pop, fileName, crs);
System.out.println("writing done");
}
示例4: decode
import org.opengis.referencing.FactoryException; //导入依赖的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);
}
示例5: setDisplayCoordinates
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
private void setDisplayCoordinates(
Double x1,
Double y1,
Double x2,
Double y2
) {
try {
convertAndDisplayBoundingBox(x1,
x2,
y1,
y2,
this.mapCRS,
this.displayCRS);
} catch (FactoryException | TransformException e) {
clearCoordinateDisplay();
log.log(Level.SEVERE, e.getMessage(), e);
}
}
示例6: NLSDEMTask
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
public NLSDEMTask(String apiKey, URI prjFileLocation, String tiffStorage) throws URISyntaxException {
if (prjFileLocation == null)
// Fallback to EPSG3067 found within JAR
prjFileLocation = NLSDEMTask.class.getResource("EPSG3067.prj").toURI();
if (tiffStorage == null)
tiffStorage = System.getProperty("java.io.tmpdir");
Path prjFile = Paths.get(prjFileLocation);
if (!Files.isReadable(prjFile))
throw new IllegalArgumentException(
".prj file " + prjFileLocation + " cannot be read. See that it exists and is readable!");
this.sourceCRS = DefaultGeographicCRS.WGS84;
try {
PrjFileReader reader = new PrjFileReader(FileChannel.open(prjFile, StandardOpenOption.READ));
targetCRS = reader.getCoordinateReferenceSystem();
transform = CRS.findMathTransform(sourceCRS, targetCRS);
} catch (FactoryException | IOException e) {
throw new IllegalArgumentException(".prj file provided is invalid!", e);
}
this.nlsXmlClient = new NLSXMLClient(apiKey, tiffStorage);
this.tiffDownloaderService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
new NLSTiffDownloaderFactory());
}
示例7: testSubCellCropWithSheer
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
@Test
public void testSubCellCropWithSheer() throws NoSuchAuthorityCodeException, TransformException, FactoryException {
ReferencedEnvelope envelope = new ReferencedEnvelope(-168.75,168.75,-78.75,78.75,DefaultGeographicCRS.WGS84);
int width = 900;
int height = 600;
int pixelsPerCell = 1;
String strategy = "Basic";
List<String> strategyArgs = null;
Float emptyCellValue = null;
Float scaleMin = 0f;
Float scaleMax = null;
boolean useLog = false;
GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, strategyArgs, emptyCellValue, scaleMin, scaleMax, useLog, envelope, width, height, null);
checkInternal(coverage, fineDelta);
}
示例8: getFilterFromParameters
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
/**
* Gets the filter from parameters.
*
* @param wifParameters
* the wif parameters
* @return the filter from parameters
* @throws MismatchedDimensionException
* the mismatched dimension exception
* @throws TransformException
* the transform exception
* @throws NoSuchAuthorityCodeException
* the no such authority code exception
* @throws FactoryException
* the factory exception
* @throws ParseException
* the parse exception
* @throws CQLException
* the cQL exception
*/
public Filter getFilterFromParameters(final Map<String, Object> wifParameters)
throws MismatchedDimensionException, TransformException,
NoSuchAuthorityCodeException, FactoryException, ParseException,
CQLException {
LOGGER.debug("getFilterFromParameters...");
String queryTxt = "";
final String polyTxt = getIntersectionPolygon(wifParameters);
if (polyTxt == null) {
LOGGER
.info("no polygon query filter received, defaulting to including all the unified area zone!");
queryTxt = "include";
} else if (polyTxt.equals("")) {
LOGGER
.info("no polygon query filter received, defaulting to including all the unified area zone!");
queryTxt = "include";
} else {
queryTxt = polyTxt;
}
LOGGER.debug("query filter: {}", queryTxt);
return getFilter(queryTxt);
}
示例9: MrGeoReader
import org.opengis.referencing.FactoryException; //导入依赖的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();
}
示例10: forSavingWith
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
public IProjection forSavingWith(final IScope scope, final String code, final boolean lonFirst)
throws FactoryException {
CoordinateReferenceSystem crs = null;
try {
crs = getCRS(scope, code, lonFirst);
} catch (final Exception e) {
crs = null;
}
if (crs == null) {
crs = getSaveCRS(scope);
}
final Projection gis = new Projection(world, this);
gis.initialCRS = crs;
// gis.computeProjection();
gis.createTransformation(gis.computeProjection(scope));
return gis;
}
示例11: testBasic
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
@Test
public void testBasic() throws NoSuchAuthorityCodeException, TransformException, FactoryException {
ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84);
int width = 8;
int height = 4;
int pixelsPerCell = 1;
String strategy = "Basic";
List<String> strategyArgs = null;
Float emptyCellValue = null;
Float scaleMin = 0f;
Float scaleMax = null;
boolean useLog = false;
GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, strategyArgs, emptyCellValue, scaleMin, scaleMax, useLog, envelope, width, height, null);
checkInternal(coverage, fineDelta);
checkEdge(coverage, envelope, fineDelta);
}
示例12: testProductSignature_DefaultWithOthers
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
@Test
public void testProductSignature_DefaultWithOthers() throws FactoryException, TransformException {
C2rccMsiOperator operator = createDefaultOperator();
operator.setOutputRpath(true);
operator.setOutputTdown(true);
operator.setOutputTup(true);
operator.setOutputOos(true);
Product targetProduct = operator.getTargetProduct();
assertDefaults(targetProduct, false);
assertBands(targetProduct, EXPECTED_RPATH_BANDS);
assertBands(targetProduct, EXPECTED_TDOWN_BANDS);
assertBands(targetProduct, EXPECTED_TUP_BANDS);
assertBands(targetProduct, EXPECTED_OOS_RTOSA);
assertBands(targetProduct, EXPECTED_OOS_RHOW);
}
示例13: createMsiTestProduct
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
private Product createMsiTestProduct() throws FactoryException, TransformException {
Product product = new Product("test-msi", "t", 1, 1);
for (String reflBandName : C2rccMsiAlgorithm.SOURCE_BAND_REFL_NAMES) {
product.addBand(reflBandName, "3863");
}
product.addBand(C2rccMsiOperator.RASTER_NAME_SUN_AZIMUTH, "42");
product.addBand(C2rccMsiOperator.RASTER_NAME_SUN_ZENITH, "42");
product.addBand(C2rccMsiOperator.RASTER_NAME_VIEW_AZIMUTH, "42");
product.addBand(C2rccMsiOperator.RASTER_NAME_VIEW_ZENITH, "42");
product.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 1, 1, 10, 50, 1, 1));
MetadataElement l1cUserProduct = new MetadataElement("Level-1C_User_Product");
MetadataElement generalInfo = new MetadataElement("General_Info");
MetadataElement productInfo = new MetadataElement("Product_Info");
productInfo.addAttribute(new MetadataAttribute("PRODUCT_START_TIME", ProductData.createInstance("2015-08-12T10:40:21.459Z"), true));
productInfo.addAttribute(new MetadataAttribute("PRODUCT_STOP_TIME", ProductData.createInstance("2015-08-12T10:40:21.459Z"), true));
MetadataElement imageCharacteristics = new MetadataElement("Product_Image_Characteristics");
imageCharacteristics.addAttribute(new MetadataAttribute("QUANTIFICATION_VALUE", ProductData.createInstance("1000"), true));
l1cUserProduct.addElement(generalInfo);
generalInfo.addElement(productInfo);
generalInfo.addElement(imageCharacteristics);
product.getMetadataRoot().addElement(l1cUserProduct);
return product;
}
示例14: CRS
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
@operator (
value = { "to_GAMA_CRS" },
category = { IOperatorCategory.SPATIAL, IOperatorCategory.SP_TRANSFORMATIONS },
concept = {})
@doc (
usages = { @usage (
value = "returns the geometry corresponding to the transformation of the given geometry to the GAMA CRS (Coordinate Reference System) assuming the given geometry is referenced by given CRS",
examples = { @example (
value = "to_GAMA_CRS({121,14}, \"EPSG:4326\")",
equals = "a geometry corresponding to the agent geometry transformed into the GAMA CRS",
test = false) }) })
public static IShape to_GAMA_CRS(final IScope scope, final IShape g, final String code) {
IProjection gis;
try {
gis = scope.getSimulation().getProjectionFactory().forSavingWith(scope, code);
} catch (final FactoryException e) {
throw GamaRuntimeException.error("The code " + code + " does not correspond to a known EPSG code",
scope);
}
if (gis == null) { return g.copy(scope); }
final IShape s = new GamaShape(gis.transform(g.getInnerGeometry()));
if (g instanceof ILocation) { return s.getLocation(); }
return s;
}
示例15: testProductSignature_DefaultWithOthers
import org.opengis.referencing.FactoryException; //导入依赖的package包/类
@Test
public void testProductSignature_DefaultWithOthers() throws FactoryException, TransformException {
C2rccMeris4Operator operator = createDefaultOperator();
operator.setOutputRpath(true);
operator.setOutputTdown(true);
operator.setOutputTup(true);
operator.setOutputOos(true);
Product targetProduct = operator.getTargetProduct();
assertDefaults(targetProduct, false);
assertBands(targetProduct, EXPECTED_RPATH_BANDS);
assertBands(targetProduct, EXPECTED_TDOWN_BANDS);
assertBands(targetProduct, EXPECTED_TUP_BANDS);
assertBands(targetProduct, EXPECTED_OOS_RTOSA);
assertBands(targetProduct, EXPECTED_OOS_RHOW);
}