Codota Logo
Geometry.setUserData
Code IndexAdd Codota to your IDE (free)

How to use
setUserData
method
in
com.vividsolutions.jts.geom.Geometry

Best Java code snippets using com.vividsolutions.jts.geom.Geometry.setUserData (Showing top 20 results out of 315)

  • Common ways to obtain Geometry
private void myMethod () {
Geometry g =
  • Codota IconGeometryCollection gc;gc.getGeometryN(n)
  • Codota IconSimpleFeature feature;(Geometry) feature.getDefaultGeometry()
  • Codota IconString wellKnownText;new WKTReader().read(wellKnownText)
  • Smart code suggestions by Codota
}
origin: osmandapp/Osmand

/**
 * 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 e) {
      //LoggerFactory.getLogger(JtsAdapter.class).error(e.getMessage(), e);
    }
  }
  return intersectedGeoms;
}
origin: osmandapp/Osmand

nextTransformGeom.setUserData(nextUserData);
origin: osmandapp/Osmand

if (nextGeom != null) {
  tileGeoms.add(nextGeom);
  nextGeom.setUserData(tagConverter.toUserData(id, nextFeature.getTagsList(), keysList, valuesList));
origin: com.vividsolutions/jts

  /**
   * Input is assumed to be a multiGeometry
   * in which every component has its userData
   * set to be a Coordinate which is the key to the output data.
   * The Coordinate is used to determine
   * the output data object to be written back into the component. 
   * 
   * @param targetGeom
   */
  public void transferData(Geometry targetGeom)
  {
    for (int i = 0; i < targetGeom.getNumGeometries(); i++) {
      Geometry geom = targetGeom.getGeometryN(i);
      Coordinate vertexKey = (Coordinate) geom.getUserData();
      if (vertexKey == null) continue;
      geom.setUserData(coordDataMap.get(vertexKey));
    }
  }
}
origin: org.geoserver.extension/querylayer

  @Override
  public void filter(Geometry g) {
    g.setUserData(crs);
  }
}
origin: com.vividsolutions/jts

  private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv)
  {
    Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
    List clipped = new ArrayList();
    for (int i = 0; i < geom.getNumGeometries(); i++) {
      Geometry g = geom.getGeometryN(i);
      Geometry result = null;
      // don't clip unless necessary
      if (clipEnv.contains(g.getEnvelopeInternal()))
          result = g;
      else if (clipEnv.intersects(g.getEnvelopeInternal())) {
        result = clipPoly.intersection(g);
        // keep vertex key info
        result.setUserData(g.getUserData());
      }

      if (result != null && ! result.isEmpty()) {
        clipped.add(result);
      }
    }
    return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
  }
}
origin: org.geotools/gt-render

public void setUserData(Object userData) {
  geometry.setUserData(userData);
}
origin: DataSystemsLab/GeoSpark

private void handleNonSpatialDataToGeometry(Geometry geometry, List<String> splitedGeometryData)
{
  LinkedList<String> splitedGeometryDataList = new LinkedList<String>(splitedGeometryData);
  if (carryInputData) {
    if (this.splitter != FileDataSplitter.GEOJSON){
      //remove spatial data position
      splitedGeometryDataList.remove(this.startOffset);
    }
    geometry.setUserData(String.join("\t", splitedGeometryDataList));
  }
}
origin: DataSystemsLab/GeoSpark

  private Geometry readGeometry(Kryo kryo, Input input)
  {
    Geometry geometry = ShapeSerde.deserialize(input, geometryFactory);
    geometry.setUserData(readUserData(kryo, input));
    return geometry;
  }
}
origin: org.datasyslab/geospark

  private Geometry readGeometry(Kryo kryo, Input input)
  {
    Geometry geometry = ShapeSerde.deserialize(input, geometryFactory);
    geometry.setUserData(readUserData(kryo, input));
    return geometry;
  }
}
origin: DataSystemsLab/GeoSpark

  public Geometry getShape(GeometryFactory geometryFactory)
      throws IOException, TypeUnknownException
  {
    ShapeParser parser = shapeType.getParser(geometryFactory);
    ByteBuffer shapeBuffer = ByteBuffer.wrap(primitiveRecord);
    Geometry shape = parser.parseShape(ShapeReaderFactory.fromByteBuffer(shapeBuffer));
    if (attributes != null) {
      shape.setUserData(attributes);
    }
    return shape;
  }
}
origin: DataSystemsLab/GeoSpark

public <T extends Geometry> void addMultiGeometry(GeometryCollection multiGeometry, List<T> result)
{
  for (int i = 0; i < multiGeometry.getNumGeometries(); i++) {
    T geometry = (T) multiGeometry.getGeometryN(i);
    geometry.setUserData(multiGeometry.getUserData());
    result.add(geometry);
  }
}
origin: org.datasyslab/geospark

  public Geometry getShape(GeometryFactory geometryFactory)
      throws IOException, TypeUnknownException
  {
    ShapeParser parser = shapeType.getParser(geometryFactory);
    ByteBuffer shapeBuffer = ByteBuffer.wrap(primitiveRecord);
    Geometry shape = parser.parseShape(ShapeReaderFactory.fromByteBuffer(shapeBuffer));
    if (attributes != null) {
      shape.setUserData(attributes);
    }
    return shape;
  }
}
origin: org.datasyslab/geospark

public <T extends Geometry> void addMultiGeometry(GeometryCollection multiGeometry, List<T> result)
{
  for (int i = 0; i < multiGeometry.getNumGeometries(); i++) {
    T geometry = (T) multiGeometry.getGeometryN(i);
    geometry.setUserData(multiGeometry.getUserData());
    result.add(geometry);
  }
}
origin: mapplus/spatial_statistics_for_geotools_udig

private Geometry removeHoles(Geometry inputPolygon) {
  Class<?> geomBinding = inputPolygon.getClass();
  Geometry finalGeom = inputPolygon;
  if (Polygon.class.equals(geomBinding)) {
    finalGeom = removeHoles((Polygon) inputPolygon);
  } else if (MultiPolygon.class.equals(geomBinding)) {
    List<Polygon> polygons = new ArrayList<Polygon>();
    for (int index = 0; index < inputPolygon.getNumGeometries(); index++) {
      Polygon polygon = (Polygon) inputPolygon.getGeometryN(index);
      polygons.add((Polygon) removeHoles(polygon));
    }
    finalGeom = inputPolygon.getFactory().createMultiPolygon(
        GeometryFactory.toPolygonArray(polygons));
  }
  finalGeom.setUserData(inputPolygon.getUserData());
  return finalGeom;
}
origin: mapplus/spatial_statistics_for_geotools_udig

private Geometry removeSmallHoles(Geometry inputPolygon, double areaTolerance) {
  Class<?> geomBinding = inputPolygon.getClass();
  Geometry finalGeom = inputPolygon;
  if (Polygon.class.equals(geomBinding)) {
    finalGeom = removeSmallHoles((Polygon) inputPolygon, areaTolerance);
  } else if (MultiPolygon.class.equals(geomBinding)) {
    List<Polygon> polygons = new ArrayList<Polygon>();
    for (int index = 0; index < inputPolygon.getNumGeometries(); index++) {
      Polygon polygon = (Polygon) inputPolygon.getGeometryN(index);
      polygons.add((Polygon) removeSmallHoles(polygon, areaTolerance));
    }
    finalGeom = inputPolygon.getFactory().createMultiPolygon(
        GeometryFactory.toPolygonArray(polygons));
  }
  finalGeom.setUserData(inputPolygon.getUserData());
  return finalGeom;
}
origin: mapplus/spatial_statistics_for_geotools_udig

private Geometry removeHoles(Polygon polygon) {
  GeometryFactory factory = polygon.getFactory();
  LineString exteriorRing = polygon.getExteriorRing();
  Geometry finalGeom = factory.createPolygon((LinearRing) exteriorRing, null);
  finalGeom.setUserData(polygon.getUserData());
  return finalGeom;
}
origin: mapplus/spatial_statistics_for_geotools_udig

  private Geometry removeHoles(Polygon polygon) {
    GeometryFactory factory = polygon.getFactory();
    LineString exteriorRing = polygon.getExteriorRing();
    Geometry finalGeom = factory.createPolygon((LinearRing) exteriorRing, null);
    finalGeom.setUserData(polygon.getUserData());
    return finalGeom;
  }
}
origin: mapplus/spatial_statistics_for_geotools_udig

  @Override
  public SimpleFeature next() throws NoSuchElementException {
    SimpleFeature feature = delegate.next();
    for (Object attribute : feature.getAttributes()) {
      if (attribute instanceof Geometry) {
        Geometry geometry = (Geometry) attribute;
        geometry.setUserData(forcedCRS);
      }
      builder.add(attribute);
    }
    return builder.buildFeature(feature.getID());
  }
}
origin: org.geotools/gt-main

  public Object visit(Literal expression, Object extraData) {
    if (!(expression.getValue() instanceof Geometry))
      return super.visit(expression, extraData);

    // check if reprojection is needed
    Geometry geom = (Geometry) expression.getValue();
    if(geom.getUserData() != null && geom.getUserData() instanceof CoordinateReferenceSystem)
      return super.visit(expression, extraData);
    
    // clone the geometry and assign the new crs
    Geometry clone = geom.getFactory().createGeometry(geom);
    clone.setUserData(defaultCrs);

    // clone
    return ff.literal(clone);
  }
}
com.vividsolutions.jts.geomGeometrysetUserData

Javadoc

A simple scheme for applications to add their own custom data to a Geometry. An example use might be to add an object representing a Coordinate Reference System.

Note that user data objects are not present in geometries created by construction methods.

Popular methods of Geometry

  • getEnvelopeInternal
    Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
  • getCoordinates
    Returns an array containing the values of all the vertices for this geometry. If the geometry is a c
  • isEmpty
    Tests whether the set of points covered by this Geometry is empty.
  • getCentroid
    Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of componen
  • getGeometryN
    Returns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).
  • toText
    Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text
  • getNumGeometries
    Returns the number of Geometrys in a GeometryCollection(or 1, if the geometry is not a collection).
  • getFactory
    Gets the factory which contains the context in which this geometry was created.
  • getGeometryType
    Returns the name of this Geometry's actual class.
  • getSRID
    Returns the ID of the Spatial Reference System used by the Geometry. JTS supports Spatial Reference
  • getCoordinate
    Returns a vertex of this Geometry (usually, but not necessarily, the first one). The returned coordi
  • intersection
    Computes a Geometry representing the point-set which is common to both this Geometry and the other
  • getCoordinate,
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply,
  • getLength

Popular in Java

  • Running tasks concurrently on multiple threads
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now