本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.setUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.setUserData方法的具體用法?Java Geometry.setUserData怎麽用?Java Geometry.setUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.Geometry
的用法示例。
在下文中一共展示了Geometry.setUserData方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: flatIntersection
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* JTS 1.14 does not support intersection on a {@link GeometryCollection}. This function works
* around this by performing intersection on a flat list of geometry. The resulting list is
* pre-filtered for invalid or empty geometry (outside of bounds). Invalid geometry are logged as
* errors.
*
* @param envelope non-list geometry defines bounding area
* @param dataGeoms geometry pre-passed through {@link #flatFeatureList(Geometry)}
* @return list of geometry from {@code data} intersecting with {@code envelope}.
*/
private static List<Geometry> flatIntersection(Geometry envelope, List<Geometry> dataGeoms) {
final List<Geometry> intersectedGeoms = new ArrayList<>(dataGeoms.size());
Geometry nextIntersected;
for (Geometry nextGeom : dataGeoms) {
try {
// AABB intersection culling
if (envelope.getEnvelopeInternal().intersects(nextGeom.getEnvelopeInternal())) {
nextIntersected = envelope.intersection(nextGeom);
if (!nextIntersected.isEmpty()) {
nextIntersected.setUserData(nextGeom.getUserData());
intersectedGeoms.add(nextIntersected);
}
}
} catch (TopologyException ex) {
LoggerFactory.getLogger(JtsAdapter.class).error(ex.getMessage(), ex);
}
}
return intersectedGeoms;
}
示例2: put
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* Adds a new geometry with attributes to the layer. NOTE THAT NEITHER
* THE SCHEMA NOR the GEOMETRY TYPE ARE CHECKED
* so you can use it in whatever way you want, at your own risks of course
* @param geom
* @param att
*/
public void put(Geometry geom, AttributesGeometry att) {
int id=geoms.size();
geom.setUserData(att);
geoms.add(id,geom);
//attsMap.put(geom.getSRID(),att);
}
示例3: apply
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry apply(String disease, Geometry g) {
@SuppressWarnings("unchecked")
Map<String, Object> attributes = (Map<String, Object>) g.getUserData();
// create random timestamp
long measurementSpace = END - START;
long timestamp = START + (long) (Math.random() * measurementSpace);
attributes.put("timestamp", timestamp);
attributes.put("disease_name", disease);
g.setUserData(attributes);
return g;
}
示例4: setAttribute
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public void setAttribute(Geometry geom, String att, Object value) {
if (!geoms.contains(geom)) {
return;
}
geom.setUserData(att);
}
示例5: read
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
@Override
public ComplexEditVDSVectorLayer read() {
GeometryImage layer = new GeometryImage(GeometryImage.POINT);
ComplexEditVDSVectorLayer cev=new ComplexEditVDSVectorLayer(null, input.getName(), layer.getGeometryType(), layer);
try {
layer.setProjection("EPSG:4326");
layer.setName(input.getName());
javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance("org.geoimage.viewer.core.io.sumoxml");
InputStream is = new FileInputStream(input );
javax.xml.bind.Unmarshaller uMarshaller = jaxbCtx.createUnmarshaller();
Object o=uMarshaller.unmarshal(is);
Analysis analysis=(Analysis)o;
SatImageMetadata imgMeta=analysis.getSatImageMetadata();
VdsAnalysis vds=analysis.getVdsAnalysis();
VdsTarget targets=analysis.getVdsTarget();
List<Geometry>boatsAA=new ArrayList<>();
List<Geometry>boatsPA=new ArrayList<>();
List<Boat>boats=targets.getBoat();
GeometryFactory factory=new GeometryFactory();
int i=0;
for(Boat b:boats){
i++;
AttributesGeometry att = new AttributesGeometry(new String[]{"x","y"});
Geometry geom=factory.createPoint(new Coordinate(b.getXpixel(),b.getYpixel()));
att.set(VDSSchema.ID, i);
att.set(VDSSchema.MAXIMUM_VALUE,b.getMaxValue());
att.set(VDSSchema.SIGNIFICANCE,b.getSignificance());
att.set(VDSSchema.THRESHOLD,b.getThresholdTile());
att.set(VDSSchema.NUMBER_OF_AGGREGATED_PIXELS,b.getNrPixels());
att.set(VDSSchema.ESTIMATED_LENGTH,b.getLength());
att.set(VDSSchema.ESTIMATED_WIDTH,b.getWidth());
att.set(VDSSchema.ESTIMATED_HEADING,b.getHeadingNorth());
geom.setUserData(att);
if(b.getReliability()==3){
if(b.getFalseAlarmCause().equals("AA"))
boatsAA.add(geom);
else
boatsPA.add(geom);
}else
layer.put(geom, att);
}
cev.addArtefactsAmbiguities(boatsPA, true);
cev.addAzimuthAmbiguities(boatsAA, true);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return cev;
}
示例6: loadMvt
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* Load an MVT to JTS geometries using coordinates. Uses {@code tagConverter} to create user data
* from feature properties.
*
* @param is stream with MVT data
* @param geomFactory allows for JTS geometry creation
* @param tagConverter converts MVT feature tags to JTS user data object.
* @param ringClassifier determines how rings are parsed into Polygons and MultiPolygons
* @return JTS MVT with geometry in MVT coordinates
* @throws IOException failure reading MVT from stream
* @see Geometry
* @see Geometry#getUserData()
* @see RingClassifier
*/
public static JtsMvt loadMvt(InputStream is,
GeometryFactory geomFactory,
ITagConverter tagConverter,
RingClassifier ringClassifier) throws IOException {
final VectorTile.Tile mvt = VectorTile.Tile.parseFrom(is);
final Vec2d cursor = new Vec2d();
final List<JtsLayer> jtsLayers = new ArrayList<>(mvt.getLayersList().size());
for (VectorTile.Tile.Layer nextLayer : mvt.getLayersList()) {
final List<String> keysList = nextLayer.getKeysList();
final List<VectorTile.Tile.Value> valuesList = nextLayer.getValuesList();
final List<Geometry> layerGeoms = new ArrayList<>(nextLayer.getFeaturesList().size());
for (VectorTile.Tile.Feature nextFeature : nextLayer.getFeaturesList()) {
final Long id = nextFeature.hasId() ? nextFeature.getId() : null;
final VectorTile.Tile.GeomType geomType = nextFeature.getType();
if (geomType == VectorTile.Tile.GeomType.UNKNOWN) {
continue;
}
final List<Integer> geomCmds = nextFeature.getGeometryList();
cursor.set(0d, 0d);
final Geometry nextGeom = readGeometry(geomCmds, geomType, geomFactory, cursor,
ringClassifier);
if (nextGeom != null) {
nextGeom.setUserData(tagConverter.toUserData(id, nextFeature.getTagsList(),
keysList, valuesList));
layerGeoms.add(nextGeom);
}
}
jtsLayers.add(new JtsLayer(nextLayer.getName(), layerGeoms));
}
return new JtsMvt(jtsLayers);
}
示例7: createTileGeom
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
* <p>Create geometry clipped and then converted to MVT 'extent' coordinates. Result
* contains both clipped geometry (intersection) and transformed geometry for encoding to
* MVT.</p>
* <p>Allows specifying separate tile and clipping coordinates. {@code clipEnvelope} can be bigger
* than {@code tileEnvelope} to have geometry exist outside the MVT tile extent.</p>
*
* @param geometryList original 'source' geometry, passed through
* {@link #flatFeatureList(Geometry)}
* @param tileEnvelope world coordinate bounds for tile, used for transforms
* @param clipEnvelope world coordinates to clip tile by
* @param geomFactory creates a geometry for the tile envelope
* @param mvtLayerParams specifies vector tile properties
* @param filter geometry values that fail filter after transforms are removed
* @return tile geometry result
* @see TileGeomResult
*/
public static TileGeomResult createTileGeom(List<Geometry> geometryList,
Envelope tileEnvelope,
Envelope clipEnvelope,
GeometryFactory geomFactory,
MvtLayerParams mvtLayerParams,
IGeometryFilter filter) {
final Geometry tileClipGeom = geomFactory.toGeometry(clipEnvelope);
final AffineTransformation t = new AffineTransformation();
final double xDiff = tileEnvelope.getWidth();
final double yDiff = tileEnvelope.getHeight();
final double xOffset = -tileEnvelope.getMinX();
final double yOffset = -tileEnvelope.getMinY();
// Transform Setup: Shift to 0 as minimum value
t.translate(xOffset, yOffset);
// Transform Setup: Scale X and Y to tile extent values, flip Y values
t.scale(1d / (xDiff / (double) mvtLayerParams.extent),
-1d / (yDiff / (double) mvtLayerParams.extent));
// Transform Setup: Bump Y values to positive quadrant
t.translate(0d, (double) mvtLayerParams.extent);
// The area contained in BOTH the 'original geometry', g, AND the 'clip envelope geometry' is
// the 'tile geometry'
final List<Geometry> intersectedGeoms = flatIntersection(tileClipGeom, geometryList);
final List<Geometry> transformedGeoms = new ArrayList<>(intersectedGeoms.size());
// Transform intersected geometry
Geometry nextTransformGeom;
Object nextUserData;
for (Geometry nextInterGeom : intersectedGeoms) {
nextUserData = nextInterGeom.getUserData();
nextTransformGeom = t.transform(nextInterGeom);
// Floating --> Integer, still contained within doubles
nextTransformGeom.apply(RoundingFilter.INSTANCE);
// TODO: Refactor line simplification
// Can't use 0d, specify value < .5d
nextTransformGeom = TopologyPreservingSimplifier.simplify(nextTransformGeom, .1d);
nextTransformGeom.setUserData(nextUserData);
// Apply filter on transformed geometry
if (filter.accept(nextTransformGeom)) {
transformedGeoms.add(nextTransformGeom);
}
}
return new TileGeomResult(intersectedGeoms, transformedGeoms);
}