org.locationtech.jts.geom.Polygon.setSRID()方法的使用及代码示例

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

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

Polygon.setSRID介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Polygon getTestPolygon() {
  WKTReader reader = new WKTReader();
  try {
    Polygon polygon = (Polygon) reader.read( "POLYGON((0 0, 50 0, 90 90, 100 0, 0 0))" );
    polygon.setSRID( getTestSrid() );
    return polygon;
  }
  catch (ParseException e) {
    throw new RuntimeException( e );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Return a testsuite-suite polygon (filter, ...)
 *
 * @return a testsuite-suite polygon
 */
public Polygon getTestPolygon() {
  WKTReader reader = new WKTReader();
  try {
    Polygon polygon = (Polygon) reader.read( TEST_POLYGON_WKT );
    polygon.setSRID( getTestSrid() );
    return polygon;
  }
  catch (ParseException e) {
    throw new RuntimeException( e );
  }
}

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

public void setSRID(int SRID) {
  polygon.setSRID(SRID);
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Converts the specified {@code Envelope} to a {@code Polygon} having the specified srid.
 *
 * @param env The envelope to convert
 * @param srid The srid for the polygon
 *
 * @return The Polygon
 */
public static Polygon toPolygon(Envelope env, int srid) {
  final Coordinate[] coords = new Coordinate[5];
  coords[0] = new Coordinate( env.getMinX(), env.getMinY() );
  coords[1] = new Coordinate( env.getMinX(), env.getMaxY() );
  coords[2] = new Coordinate( env.getMaxX(), env.getMaxY() );
  coords[3] = new Coordinate( env.getMaxX(), env.getMinY() );
  coords[4] = new Coordinate( env.getMinX(), env.getMinY() );
  final LinearRing shell = geomFactory.createLinearRing( coords );
  final Polygon pg = geomFactory.createPolygon( shell, null );
  pg.setSRID( srid );
  return pg;
}

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

/**
   * Returns the completed OGC Polygon.
   *
   * @param geometryFactory Geometry factory to be used in Polygon creation.
   * @return Completed OGC Polygon.
   */
  public Geometry create(GeometryFactory geometryFactory) {
    for (int i = 0; i < innerBoundaries.size(); i++) {
      LinearRing hole = (LinearRing) innerBoundaries.get(i);
      if (hole.crosses(outerBoundary)) {
        LOGGER.warning("Topology Error building polygon");

        return null;
      }
    }

    LinearRing[] rings =
        (LinearRing[]) innerBoundaries.toArray(new LinearRing[innerBoundaries.size()]);
    Polygon polygon = geometryFactory.createPolygon(outerBoundary, rings);
    polygon.setUserData(getSRS());
    polygon.setSRID(getSRID());
    return polygon;
  }
}

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

poly.setSRID(SRID);

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

LOGGER.exiting("SubHandlerBox", "create", polygon);
polygon.setUserData(getSRS());
polygon.setSRID(getSRID());

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

/**
   * Creates a rectangular Polygon formed from the minima and maxima by the
   * given shell.
   * The user can set a srid.
   * @param xmin X min
   * @param ymin Y min
   * @param xmax X max
   * @param ymax Y max
   * @param srid SRID
   * @return Envelope as a POLYGON
   */
  public static Polygon makeEnvelope(double xmin, double ymin, double xmax, double ymax, int srid) {
    Polygon geom = makeEnvelope(xmin, ymin, xmax, ymax);
    geom.setSRID(srid);
    return geom;
  }
}

代码示例来源:origin: locationtech/jts

public Object parse(Handler arg, GeometryFactory gf) throws SAXException {
    // one child, either a coord
    // or a coordinate sequence
    
    if(arg.children.size()<1)
      throw new SAXException("Cannot create a polygon without atleast one linear ring");
    int srid = getSrid(arg.attrs,gf.getSRID());
    
    LinearRing outer = (LinearRing) arg.children.get(0); // will be the first
    List t = arg.children.size()>1?arg.children.subList(1,arg.children.size()):null;
    LinearRing[] inner = t==null?null:(LinearRing[]) t.toArray(new LinearRing[t.size()]);
    
    Polygon p = gf.createPolygon(outer,inner);
    
    if(p.getSRID()!=srid)
      p.setSRID(srid);
    
    return p;
  }
});

代码示例来源:origin: geoserver/geofence

/**
 * Creates the polygon.
 *
 * @param wkt
 *            the wkt
 * @return the polygon
 * @throws ParseException
 *             the parse exception
 */
public Polygon createPolygon(String wkt) throws ParseException
{
  Polygon poly = polAdapter.unmarshal(wkt);
  if (poly.getSRID() == 0)
  {
    poly.setSRID(4326);
  }
  return poly;
}

代码示例来源:origin: org.geoserver.geofence/geofence-model-internal

@Override
  public String marshal(Polygon the_geom) throws ParseException {
    if (the_geom != null) {
      WKTWriter wktWriter = new WKTWriter();
      if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

      return wktWriter.write(the_geom);
    } else {
      throw new ParseException("Polygon obj is null.");
    }
  }
}

代码示例来源:origin: geoserver/geofence

@Override
  public String marshal(Polygon the_geom) throws ParseException {
    if (the_geom != null) {
      WKTWriter wktWriter = new WKTWriter();
      if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

      return wktWriter.write(the_geom);
    } else {
      throw new ParseException("Polygon obj is null.");
    }
  }
}

代码示例来源:origin: org.geoserver.geofence/geofence-model

@Override
  public String marshal(Polygon the_geom) throws ParseException {
    if (the_geom != null) {
      WKTWriter wktWriter = new WKTWriter();
      if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

      return wktWriter.write(the_geom);
    } else {
      throw new ParseException("Polygon obj is null.");
    }
  }
}

代码示例来源:origin: geoserver/geofence

@Override
  public String marshal(Polygon the_geom) throws ParseException {
    if (the_geom != null) {
      WKTWriter wktWriter = new WKTWriter();
      if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

      return wktWriter.write(the_geom);
    } else {
      throw new ParseException("Polygon obj is null.");
    }
  }
}

代码示例来源:origin: Geomatys/geotoolkit

/**
 * {@inheritDoc }
 */
@Override
public org.locationtech.jts.geom.Geometry computeJTSPeer() {
  final SurfaceBoundary boundary = getBoundary();
  final Ring exterior = boundary.getExterior();
  final List interiors = boundary.getInteriors();
  if (exterior != null) {
    final org.locationtech.jts.geom.Geometry g = ((JTSGeometry) exterior).getJTSGeometry();
    final int numHoles = (interiors != null) ? interiors.size() : 0;
    final org.locationtech.jts.geom.LinearRing jtsExterior = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g.getCoordinates());
    final org.locationtech.jts.geom.LinearRing [] jtsInterior = new org.locationtech.jts.geom.LinearRing[numHoles];
    for (int i=0; i<numHoles; i++) {
      final org.locationtech.jts.geom.Geometry g2 =
        ((JTSGeometry) interiors.get(i)).getJTSGeometry();
      jtsInterior[i] = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g2.getCoordinates());
    }
    final org.locationtech.jts.geom.Polygon result =
      JTSUtils.GEOMETRY_FACTORY.createPolygon(jtsExterior, jtsInterior);
    final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
    if (crs != null) {
      final int srid = SRIDGenerator.toSRID(crs, Version.V1);
      result.setSRID(srid);
    }
    return result;
  }
  return null;
}

相关文章