com.vividsolutions.jts.geom.Polygon.getFactory()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中com.vividsolutions.jts.geom.Polygon.getFactory()方法的一些代码示例,展示了Polygon.getFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.getFactory()方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:getFactory

Polygon.getFactory介绍

暂无

代码示例

代码示例来源:origin: com.vividsolutions/jts

/**
 * Computes the boundary of this geometry
 *
 * @return a lineal geometry (which may be empty)
 * @see Geometry#getBoundary
 */
public Geometry getBoundary() {
 if (isEmpty()) {
  return getFactory().createMultiLineString(null);
 }
 LinearRing[] rings = new LinearRing[holes.length + 1];
 rings[0] = shell;
 for (int i = 0; i < holes.length; i++) {
  rings[i + 1] = holes[i];
 }
 // create LineString or MultiLineString as appropriate
 if (rings.length <= 1)
  return getFactory().createLinearRing(rings[0].getCoordinateSequence());
 return getFactory().createMultiLineString(rings);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 *  Constructs a <code>Polygon</code> with the given exterior boundary and
 *  interior boundaries.
 *
 *@param  shell           the outer boundary of the new <code>Polygon</code>,
 *      or <code>null</code> or an empty <code>LinearRing</code> if the empty
 *      geometry is to be created.
 *@param  holes           the inner boundaries of the new <code>Polygon</code>
 *      , or <code>null</code> or empty <code>LinearRing</code>s if the empty
 *      geometry is to be created.
 */
public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory) {
 super(factory);
 if (shell == null) {
  shell = getFactory().createLinearRing((CoordinateSequence)null);
 }
 if (holes == null) {
  holes = new LinearRing[]{};
 }
 if (hasNullElements(holes)) {
  throw new IllegalArgumentException("holes must not contain null elements");
 }
 if (shell.isEmpty() && hasNonEmptyElements(holes)) {
  throw new IllegalArgumentException("shell is empty but holes are not");
 }
 this.shell = shell;
 this.holes = holes;
}

代码示例来源:origin: org.geotools/gt-render

public GeometryFactory getFactory() {
  return polygon.getFactory();
}

代码示例来源:origin: org.orbisgis/h2gis

/**
   * Create a new polygon without hole.
   *
   * @param polygon
   * @return
   */
  public static Polygon removeHolesPolygon(Polygon polygon) {
    return new Polygon((LinearRing) polygon.getExteriorRing(), null, polygon.getFactory());
  }
}

代码示例来源:origin: org.orbisgis/orbisgis-core

/**
 * Create a new polygon without hole.
 *
 * @param polygon
 * @return
 */
public static Polygon removeHolePolygon(Polygon polygon) {
  return new Polygon((LinearRing) polygon.getExteriorRing(), null, polygon.getFactory());
}

代码示例来源:origin: org.orbisgis/h2gis-functions

/**
   * Create a new polygon without hole.
   *
   * @param polygon
   * @return
   */
  public static Polygon removeHolesPolygon(Polygon polygon) {
    return new Polygon((LinearRing) polygon.getExteriorRing(), null, polygon.getFactory());
  }
}

代码示例来源:origin: com.vividsolutions/jts-core

/**
 * Computes the boundary of this geometry
 *
 * @return a lineal geometry (which may be empty)
 * @see Geometry#getBoundary
 */
public Geometry getBoundary() {
 if (isEmpty()) {
  return getFactory().createMultiLineString(null);
 }
 LinearRing[] rings = new LinearRing[holes.length + 1];
 rings[0] = shell;
 for (int i = 0; i < holes.length; i++) {
  rings[i + 1] = holes[i];
 }
 // create LineString or MultiLineString as appropriate
 if (rings.length <= 1)
  return getFactory().createLinearRing(rings[0].getCoordinateSequence());
 return getFactory().createMultiLineString(rings);
}

代码示例来源:origin: teiid/teiid

protected static Polygon transformPolygon(CoordinateTransform ct,
                     Polygon polygon) {
  return polygon.getFactory().createPolygon(transformCoordinates(ct, polygon.getCoordinates()));
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

protected static Polygon transformPolygon(CoordinateTransform ct,
                     Polygon polygon) {
  return polygon.getFactory().createPolygon(transformCoordinates(ct, polygon.getCoordinates()));
}

代码示例来源:origin: org.teiid/teiid-engine

protected static Polygon transformPolygon(CoordinateTransform ct,
                     Polygon polygon) {
  return polygon.getFactory().createPolygon(transformCoordinates(ct, polygon.getCoordinates()));
}

代码示例来源: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: org.geotools/gt-main

/**
 * Clips a polygon using the Liang-Barsky helper routine. Does not generate, in general,
 * valid polygons (but still does generate polygons good enough for rendering)
 * @param polygon
 * @return
 */
private Geometry clipPolygon(Polygon polygon) {
  final GeometryFactory gf = polygon.getFactory();
  LinearRing exterior = (LinearRing) polygon.getExteriorRing();
  LinearRing shell = polygonClip(exterior);
  if(shell == null || shell.isEmpty()) {
    return null;
  }
  List<LinearRing> holes = new ArrayList<LinearRing>();
  for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
    LinearRing hole = (LinearRing) polygon.getInteriorRingN(i);
    hole = polygonClip(hole);
    if(hole != null && !hole.isEmpty()) {
      holes.add(hole);
    }
  }
  return gf.createPolygon(shell, (LinearRing[]) holes.toArray(new LinearRing[holes.size()]));
}

代码示例来源:origin: org.orbisgis/h2gis

/**
 * Drape a polygon on a set of triangles
 * @param p
 * @param triangles
 * @param sTRtree
 * @return 
 */
public static Geometry drapePolygon(Polygon p, Geometry triangles, STRtree sTRtree) {
  GeometryFactory factory = p.getFactory();
  //Split the triangles in lines to perform all intersections
  Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true);        
  Polygon splittedP = processPolygon(p, triangleLines, factory);
  CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree);
  splittedP.apply(drapeFilter);
  return splittedP;
}

代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig

private Geometry removeSmallHoles(Polygon polygon, double areaTolerance) {
    GeometryFactory factory = polygon.getFactory();
    LineString exteriorRing = polygon.getExteriorRing();
    // check interior rings
    List<LinearRing> interiorRingList = new ArrayList<LinearRing>();
    for (int index = 0; index < polygon.getNumInteriorRing(); index++) {
      LineString interiorRing = polygon.getInteriorRingN(index);
      if (interiorRing.isRing()) {
        if (Math.abs(interiorRing.getArea()) >= areaTolerance) {
          interiorRingList.add((LinearRing) interiorRing);
        }
      }
    }
    LinearRing[] holes = null;
    if (interiorRingList.size() > 0) {
      holes = GeometryFactory.toLinearRingArray(interiorRingList);
    }
    Geometry finalGeom = factory.createPolygon((LinearRing) exteriorRing, holes);
    finalGeom.setUserData(polygon.getUserData());
    return finalGeom;
  }
}

代码示例来源:origin: org.geotools/gt-oracle-spatial

/**
 * Add ordinates for polygon - with hole support.
 * 
 * <p>
 * Ensure ordinates are added in the correct orientation as External or
 * Internal polygons.
 * </p>
 *
 * @param list List to add coordiantes to
 * @param polygon Polygon to be encoded
 */
private static void addCoordinatesInterpretation1(List list, Polygon polygon) {
  int holes = polygon.getNumInteriorRing();
  addCoordinates(list,
    counterClockWise(polygon.getFactory().getCoordinateSequenceFactory(),
      polygon.getExteriorRing().getCoordinateSequence()));
  for (int i = 0; i < holes; i++) {
    addCoordinates(list,
      clockWise(polygon.getFactory().getCoordinateSequenceFactory(),
        polygon.getInteriorRingN(i).getCoordinateSequence()));
  }
}

代码示例来源:origin: org.orbisgis/h2gis

/**
 * Reverse the polygon to be oriented clockwise
 * @param polygon
 * @return 
 */
private static Polygon extractFloor(final Polygon polygon) {
  GeometryFactory factory = polygon.getFactory();
  final LinearRing shell = factory.createLinearRing(getClockWise(
      polygon.getExteriorRing()).getCoordinates());
  final int nbOfHoles = polygon.getNumInteriorRing();
  final LinearRing[] holes = new LinearRing[nbOfHoles];
  for (int i = 0; i < nbOfHoles; i++) {
    holes[i] = factory.createLinearRing(getCounterClockWise(
        polygon.getInteriorRingN(i)).getCoordinates());
  }
  return factory.createPolygon(shell, holes);
}

代码示例来源:origin: org.orbisgis/h2gis-functions

/**
 * Reverse the polygon to be oriented clockwise
 * @param polygon
 * @return 
 */
private static Polygon extractFloor(final Polygon polygon) {
  GeometryFactory factory = polygon.getFactory();
  final LinearRing shell = factory.createLinearRing(getClockWise(
      polygon.getExteriorRing()).getCoordinates());
  final int nbOfHoles = polygon.getNumInteriorRing();
  final LinearRing[] holes = new LinearRing[nbOfHoles];
  for (int i = 0; i < nbOfHoles; i++) {
    holes[i] = factory.createLinearRing(getCounterClockWise(
        polygon.getInteriorRingN(i)).getCoordinates());
  }
  return factory.createPolygon(shell, holes);
}

代码示例来源:origin: org.orbisgis/h2gis

/**
 * Extract the roof of a polygon
 * 
 * @param polygon
 * @param height
 * @return 
 */
public static Polygon extractRoof(Polygon polygon, double height) {
  GeometryFactory factory = polygon.getFactory();
  Polygon roofP = (Polygon) polygon.clone();
  roofP.apply(new TranslateCoordinateSequenceFilter(height));
  final LinearRing shell = factory.createLinearRing(getCounterClockWise(roofP.getExteriorRing()).getCoordinates());
  final int nbOfHoles = roofP.getNumInteriorRing();
  final LinearRing[] holes = new LinearRing[nbOfHoles];
  for (int i = 0; i < nbOfHoles; i++) {
    holes[i] = factory.createLinearRing(getClockWise(
        roofP.getInteriorRingN(i)).getCoordinates());
  }
  return factory.createPolygon(shell, holes);
}

代码示例来源:origin: org.orbisgis/h2gis-functions

/**
 * Extract the roof of a polygon
 * 
 * @param polygon
 * @param height
 * @return 
 */
public static Polygon extractRoof(Polygon polygon, double height) {
  GeometryFactory factory = polygon.getFactory();
  Polygon roofP = (Polygon) polygon.clone();
  roofP.apply(new TranslateCoordinateSequenceFilter(height));
  final LinearRing shell = factory.createLinearRing(getCounterClockWise(roofP.getExteriorRing()).getCoordinates());
  final int nbOfHoles = roofP.getNumInteriorRing();
  final LinearRing[] holes = new LinearRing[nbOfHoles];
  for (int i = 0; i < nbOfHoles; i++) {
    holes[i] = factory.createLinearRing(getClockWise(
        roofP.getInteriorRingN(i)).getCoordinates());
  }
  return factory.createPolygon(shell, holes);
}

相关文章