本文整理汇总了Java中org.opengis.geometry.DirectPosition.getOrdinate方法的典型用法代码示例。如果您正苦于以下问题:Java DirectPosition.getOrdinate方法的具体用法?Java DirectPosition.getOrdinate怎么用?Java DirectPosition.getOrdinate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opengis.geometry.DirectPosition
的用法示例。
在下文中一共展示了DirectPosition.getOrdinate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGeoPosition
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
* Convert {@link DirectPosition} into a {@link GeoPosition}
*
* @param position
* @return Returns a {@link GeoPosition}
*/
private static GeoPosition getGeoPosition(final DirectPosition position) {
double latitude = 0;
double longitude = 0;
final int dimension = position.getDimension();
for (int dimensionIndex = 0; dimensionIndex < dimension; dimensionIndex++) {
if (dimensionIndex == 0) {
longitude = position.getOrdinate(dimensionIndex);
} else if (dimensionIndex == 1) {
latitude = position.getOrdinate(dimensionIndex);
}
}
return new GeoPosition(latitude, longitude);
}
示例2: getPixelSize
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
* Utility methods
*/
private double[] getPixelSize(GeoCoding sourceGeoCoding, CoordinateReferenceSystem targetCRS) {
double[] size = null;
try {
size = new double[2];
DirectPosition geoPos1 = sourceGeoCoding.getImageToMapTransform()
.transform(new DirectPosition2D(0, 0), null);
Coordinate c1 = new Coordinate(geoPos1.getOrdinate(0), geoPos1.getOrdinate(1));
DirectPosition geoPos2 = sourceGeoCoding.getImageToMapTransform()
.transform(new DirectPosition2D(0, 1), null);
Coordinate c2 = new Coordinate(geoPos2.getOrdinate(0), geoPos2.getOrdinate(1));
DirectPosition geoPos3 = sourceGeoCoding.getImageToMapTransform()
.transform(new DirectPosition2D(1, 0), null);
Coordinate c3 = new Coordinate(geoPos3.getOrdinate(0), geoPos3.getOrdinate(1));
final CoordinateReferenceSystem sourceCRS = sourceGeoCoding.getMapCRS();
size[0] = distance(sourceCRS, targetCRS, c3, c1);
size[1] = distance(sourceCRS, targetCRS, c2, c1);
} catch (TransformException tex) {
tex.printStackTrace();
}
return size;
}
示例3: eastNorthToLatLong
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
public static Coordinate eastNorthToLatLong(double x, double y, String sourceCrs, String targetCrs) throws FactoryException, MismatchedDimensionException, TransformException {
CoordinateReferenceSystem targetCrsDecoded = CRS.decode(targetCrs);
CoordinateReferenceSystem sourceCrsDecoded = CRS.decode(sourceCrs);
CoordinateOperation op = new DefaultCoordinateOperationFactory().createOperation(sourceCrsDecoded, targetCrsDecoded);
DirectPosition source = new GeneralDirectPosition(x, y);
DirectPosition target = op.getMathTransform().transform(source, null);
Double targetX = target.getOrdinate(0);
Double targetY = target.getOrdinate(1);
return new Coordinate(targetY, targetX);
}
示例4: createBandImages
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
* STEP 5 methods
*/
private void createBandImages() throws TransformException {
for (Band band : this.targetProduct.getBands()) {
Band[] srcBands = new Band[this.sourceProducts.length];
for (int index = 0; index < this.sourceProducts.length; index++){
for(MosaicOp.Variable outputVariable : this.variables) {
if(outputVariable.getName().equals(band.getName())) {
srcBands[index] = this.sourceProducts[index].getBand(getSourceBandName(outputVariable.getExpression()));
}
}
}
final Dimension tileSize = JAIUtils.computePreferredTileSize(band.getRasterWidth(), band.getRasterHeight(), 1);
int levels = srcBands[0].getSourceImage().getModel().getLevelCount();
for(Product product: this.sourceProducts){
int lowestLevel = product.getBandAt(0).getSourceImage().getModel().getLevelCount();
if(lowestLevel < levels){
levels = lowestLevel;
}
}
MathTransform mapTransform = band.getGeoCoding().getImageToMapTransform();
DirectPosition bandOrigin = mapTransform.transform(new DirectPosition2D(0, 0), null);
S2MosaicMultiLevelSource bandSource =
new S2MosaicMultiLevelSource(srcBands,
bandOrigin.getOrdinate(0),
bandOrigin.getOrdinate(1),
band.getRasterWidth(), band.getRasterHeight(),
tileSize.width, tileSize.height, levels,
band.getGeoCoding(),
this.overlappingMethod);
band.setSourceImage(new DefaultMultiLevelImage(bandSource));
}
}
示例5: getPatchCoordinates
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
* Returns the patch coordinates for a tile rectangle.
*
* @param r The tile rectangle (only {@code r.x} and {@code r.y} are used).
* @param t The image-to-map transform used for the tile.
*
* @return the patch coordinates.
*
* @throws TransformException
*/
public Point getPatchCoordinates(Rectangle r, MathTransform t) throws TransformException {
final DirectPosition p = new DirectPosition2D(r.getX(), r.getY());
t.transform(p, p);
final double lon = p.getOrdinate(0);
final double lat = p.getOrdinate(1);
final int patchX = getPatchX(lon);
final int patchY = getPatchY(lat);
return new Point(patchX, patchY);
}
示例6: createSubsetProducts
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
private List<Product> createSubsetProducts() {
List<Product> subsetProducts = new ArrayList<>();
for (Product product : this.sourceProducts) {
Rectangle2D productArea = new Rectangle2D.Double();
final GeoCoding geoCoding = product.getSceneGeoCoding();
GeoPos minPoint = geoCoding.getGeoPos(new PixelPos(0, 0), null);
GeoPos maxPoint = geoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth(),
product.getSceneRasterHeight()), null);
productArea.setFrameFromDiagonal(minPoint.getLon(), minPoint.getLat(),
maxPoint.getLon(), maxPoint.getLat());
ReferencedEnvelope productEnvelope = new ReferencedEnvelope(productArea, this.targetCRS);
final DirectPosition targetLower = this.targetEnvelope.getLowerCorner();
final DirectPosition targetUpper = this.targetEnvelope.getUpperCorner();
final DirectPosition productLower = productEnvelope.getLowerCorner();
final DirectPosition productUpper = productEnvelope.getUpperCorner();
if (targetLower.getOrdinate(0) > productLower.getOrdinate(0) ||
targetLower.getOrdinate(1) > productLower.getOrdinate(1) ||
targetUpper.getOrdinate(0) < productUpper.getOrdinate(0) ||
targetUpper.getOrdinate(1) < productUpper.getOrdinate(1)) {
final HashMap<String, Product> sourceProductMap = new HashMap<>();
sourceProductMap.put("source", product);
final HashMap<String, Object> subsetParams = new HashMap<>();
subsetParams.put("bandNames", product.getBandNames());
subsetParams.put("copyMetadata", true);
Envelope intersection = productEnvelope.intersection(this.targetEnvelope);
String builder = "POLYGON((" +
intersection.getMinX() + " " + intersection.getMinY() + "," +
intersection.getMinX() + " " + intersection.getMaxY() + "," +
intersection.getMaxX() + " " + intersection.getMaxY() + "," +
intersection.getMaxX() + " " + intersection.getMinY() + "," +
intersection.getMinX() + " " + intersection.getMinY() +
"))";
subsetParams.put("geoRegion", builder);
subsetProducts.add(GPF.createProduct("Subset", subsetParams, sourceProductMap));
} else {
subsetProducts.add(product);
}
}
return subsetProducts;
}
示例7: buildSurroundingGeometries
import org.opengis.geometry.DirectPosition; //导入方法依赖的package包/类
/**
* Build geometries with the provided coordinate at the center. The width of
* the geometry is twice the distance provided. More than one geometry is
* return when passing the date line.
*
* @param distances
* [x,y] = [longitude, latitude]
* @param unit
* @param coordinate
* @return
*/
public List<Geometry> buildSurroundingGeometries(
final double[] distances,
final Unit<Length> unit,
Coordinate coordinate ) {
List<Geometry> geos = new LinkedList<Geometry>();
GeodeticCalculator geoCalc = new GeodeticCalculator();
geoCalc.setStartingGeographicPoint(
coordinate.x,
coordinate.y);
try {
geoCalc.setDirection(
0,
unit.getConverterTo(
SI.METER).convert(
distances[1]));
DirectPosition north = geoCalc.getDestinationPosition();
geoCalc.setDirection(
90,
unit.getConverterTo(
SI.METER).convert(
distances[0]));
DirectPosition east = geoCalc.getDestinationPosition();
geoCalc.setStartingGeographicPoint(
coordinate.x,
coordinate.y);
geoCalc.setDirection(
-90,
unit.getConverterTo(
SI.METER).convert(
distances[0]));
DirectPosition west = geoCalc.getDestinationPosition();
geoCalc.setDirection(
180,
unit.getConverterTo(
SI.METER).convert(
distances[1]));
DirectPosition south = geoCalc.getDestinationPosition();
double x1 = west.getOrdinate(0);
double x2 = east.getOrdinate(0);
double y1 = north.getOrdinate(1);
double y2 = south.getOrdinate(1);
handleBoundaries(
geos,
coordinate,
x1,
x2,
y1,
y2);
return geos;
}
catch (IllegalArgumentException | IndexOutOfBoundsException | TransformException | ConversionException ex) {
LOGGER.error(
"Unable to build geometry",
ex);
}
return null;
}