Java Code Examples for com.vividsolutions.jts.geom.Coordinate

The following examples show how to use com.vividsolutions.jts.geom.Coordinate. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: jts   Author: metteo   File: MiscellaneousTest.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testCoordinateNaN() {
  Coordinate c1 = new Coordinate();
  assertTrue(! Double.isNaN(c1.x));
  assertTrue(! Double.isNaN(c1.y));
  assertTrue(Double.isNaN(c1.z));

  Coordinate c2 = new Coordinate(3,4);
  assertEquals(3,c2.x,1E-10);
  assertEquals(4,c2.y,1E-10);
  assertTrue(Double.isNaN(c2.z));

  assertEquals(c1,c1);
  assertEquals(c2,c2);
  assertTrue(! c1.equals(c2));
  assertEquals(new Coordinate(),new Coordinate(0,0));
  assertEquals(new Coordinate(3,5),new Coordinate(3,5));
  assertEquals(new Coordinate(3,5,Double.NaN),new Coordinate(3,5,Double.NaN));
  assertTrue(new Coordinate(3,5,0).equals(new Coordinate(3,5,Double.NaN)));
}
 
Example #2
/**
 * Initialize this painter with all the info it needs.
 * 
 * @param layer
 *            The vector layer wherein the tiles lie.
 * @param style
 *            The rendering style.
 * @param renderer
 *            Rendering output type: "SVG" or "VML".
 * @param scale
 *            The current client-side scale. Needed for creating the world to view space coordinate transformer.
 * @param panOrigin
 *            The current origin may differ, depending on whether or not the client has been panning.Needed for
 *            creating the world to view space coordinate transformer.
 * @param geoService
 *            geo service for geometry conversions
 * @param textService
 *            text service for string sizes
 */
public StringContentTilePainter(VectorLayer layer, NamedStyleInfo style, String renderer, double scale,
		Coordinate panOrigin, GeoService geoService, TextService textService) {
	this.layer = layer;
	// @todo: duplicate code, can we just depend on the VectorLayerService ?
	if (style == null) {
		// no style specified, take the first
		style = layer.getLayerInfo().getNamedStyleInfos().get(0);
	} else if (style.getFeatureStyles().isEmpty()) {
		// only name specified, find it
		style = layer.getLayerInfo().getNamedStyleInfo(style.getName());
	}

	this.style = style;
	this.renderer = renderer;
	this.scale = scale;
	this.panOrigin = panOrigin;
	this.geoService = geoService;
	this.textService = textService;
}
 
Example #3
/**
 * Apply clipping to the features in a tile. The tile and its features should already be in map space.
 *
 * @param tile
 *            tile to put features in
 * @param scale
 *            scale
 * @param panOrigin
 *            When panning on the client, only this parameter changes. So we need to be aware of it as we calculate
 *            the maxScreenEnvelope.
 * @throws GeomajasException oops
 */
public void clipTile(InternalTile tile, double scale, Coordinate panOrigin) throws GeomajasException {
	log.debug("clipTile before {}", tile);
	List<InternalFeature> orgFeatures = tile.getFeatures();
	tile.setFeatures(new ArrayList<InternalFeature>());
	Geometry maxScreenBbox = null; // The tile's maximum bounds in screen space. Used for clipping.
	for (InternalFeature feature : orgFeatures) {
		// clip feature if necessary
		if (exceedsScreenDimensions(feature, scale)) {
			log.debug("feature {} exceeds screen dimensions", feature);
			InternalFeatureImpl vectorFeature = (InternalFeatureImpl) feature.clone();
			tile.setClipped(true);
			vectorFeature.setClipped(true);
			if (null == maxScreenBbox) {
				maxScreenBbox = JTS.toGeometry(getMaxScreenEnvelope(tile, panOrigin));
			}
			Geometry clipped = maxScreenBbox.intersection(feature.getGeometry());
			vectorFeature.setClippedGeometry(clipped);
			tile.addFeature(vectorFeature);
		} else {
			tile.addFeature(feature);
		}
	}
	log.debug("clipTile after {}", tile);
}
 
Example #4
Source Project: coordination_oru   Author: FedericoPecora   File: BezierSplineFactory.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static Coordinate[] createBezierSpline(Coordinate p1, Coordinate p2, Coordinate p3, Coordinate p4, double dist) {
	ArrayList<Coordinate> ret = new ArrayList<Coordinate>();
	double t = 0.0;
	Coordinate prevCoord = p1;
	ret.add(prevCoord);
	do {
		Coordinate coord = cubicBezier(p1, p2, p3, p4, t);
		if (prevCoord.distance(coord) >= dist) {
			ret.add(coord);
			prevCoord = coord;
		}
		t += 0.01;
	}
	while (t < 1.0);
	if (ret.get(ret.size()-1).distance(p4) > dist/4.0) ret.add(p4);
	return ret.toArray(new Coordinate[ret.size()]);
}
 
Example #5
Source Project: chuidiang-ejemplos   Author: chuidiang   File: Main.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void updateGeometry(SessionFactory sessionFactory) {
    Session session = sessionFactory.openSession();

    session.beginTransaction();

    TheData theData = session.get(TheData.class, 1L);

    LineString geometry = geometryFactory.createLineString(new Coordinate[]{
            new Coordinate(5,6),
            new Coordinate(7,8),
            new Coordinate(9,10)});
    theData.setTheGeometry(geometry);

    session.saveOrUpdate(theData);
    session.getTransaction().commit();
    session.close();
}
 
Example #6
Source Project: jts   Author: metteo   File: ValidPanel.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
void btnSimple_actionPerformed(ActionEvent e) 
{
	boolean isSimple = true;
	Coordinate nonSimpleLoc = null;
	if (testCase.getGeometry(0) != null) {
    IsSimpleOp simpleOp = new IsSimpleOp(testCase.getGeometry(0));
    isSimple = simpleOp.isSimple();
    nonSimpleLoc = simpleOp.getNonSimpleLocation(); 
  }
  String msg = isSimple ?
  		""
  		: "Self-intersection at " + WKTWriter.toPoint(nonSimpleLoc);
  taInvalidMsg.setText(msg);
  txtIsValid.setText(isSimple ? "Y" : "N");
  setMarkPoint(nonSimpleLoc);
}
 
Example #7
Source Project: jts   Author: metteo   File: AbstractStreamDrawTool.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void mouseLocationChanged(MouseEvent e) {
  try {
    if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) 
        == InputEvent.BUTTON1_DOWN_MASK) {
      Coordinate newCoord = toModelCoordinate(e.getPoint());
      if (newCoord.distance(lastCoordinate()) < gridSize())
        return;
      //add(toModelSnapped(e.getPoint()));
      add(newCoord);
    }

    tentativeCoordinate = toModelSnapped(e.getPoint());
    redrawIndicator();
  } catch (Throwable t) {
  }
}
 
Example #8
@Override
public void calculateSize(PdfContext context) {
	setMapId(getMap().getMapId());
	setRasterResolution(getMap().getRasterResolution());

	// calculate origin (uses margins to position)
	Coordinate mapOrigin = getMap().getLocation();
	Coordinate portOrigin = getLocation();
	if (userX == -1) {
		getConstraint().setMarginX((float) (portOrigin.x - mapOrigin.x) * getMap().getPpUnit());
	} else {
		getConstraint().setMarginX(userX);
	}
	if (userY == -1) {
		getConstraint().setMarginY((float) (portOrigin.y - mapOrigin.y) * getMap().getPpUnit());
	} else {
		getConstraint().setMarginY(userY);
	}

	// calculate ppunit
	setPpUnit(getMap().getPpUnit() * zoomScale);
	super.calculateSize(context);
}
 
Example #9
Source Project: gama   Author: gama-platform   File: GamaGeometryType.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static IShape buildHexagon(final double sizeX, final double sizeY, final ILocation location) {
	final double x = location.getX();
	final double y = location.getY();
	final Coordinate[] coords = new Coordinate[7];
	coords[0] = new GamaPoint(x - sizeX / 2.0, y);
	coords[1] = new GamaPoint(x - sizeX / 4, y + sizeY / 2);
	coords[2] = new GamaPoint(x + sizeX / 4, y + sizeY / 2);
	coords[3] = new GamaPoint(x + sizeX / 2, y);
	coords[4] = new GamaPoint(x + sizeX / 4, y - sizeY / 2);
	coords[5] = new GamaPoint(x - sizeX / 4, y - sizeY / 2);
	coords[6] = new GamaPoint(coords[0]);
	final Geometry g = GeometryUtils.GEOMETRY_FACTORY
			.createPolygon(GeometryUtils.GEOMETRY_FACTORY.createLinearRing(coords), null);
	return new GamaShape(g);

}
 
Example #10
Source Project: jts   Author: metteo   File: CreateRandomShapeFunctions.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Geometry randomSegmentsInGrid(Geometry g, int nPts) {
  Envelope env = FunctionsUtil.getEnvelopeOrDefault(g);
  GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(g);

  int nCell = (int) Math.sqrt(nPts) + 1;

  double xLen = env.getWidth() / nCell;
  double yLen = env.getHeight() / nCell;

  List lines = new ArrayList();

  for (int i = 0; i < nCell; i++) {
    for (int j = 0; j < nCell; j++) {
      double x0 = env.getMinX() + i * xLen + xLen * Math.random();
      double y0 = env.getMinY() + j * yLen + yLen * Math.random();
      double x1 = env.getMinX() + i * xLen + xLen * Math.random();
      double y1 = env.getMinY() + j * yLen + yLen * Math.random();
      lines.add(geomFact.createLineString(new Coordinate[] {
          new Coordinate(x0, y0), new Coordinate(x1, y1) }));
    }
  }
  return geomFact.buildGeometry(lines);
}
 
Example #11
Source Project: coordination_oru   Author: FedericoPecora   File: AbstractTrajectoryEnvelopeCoordinator.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Generate obstacles representing the placement(s) of a given robot in given poses.
 * @param robotID The ID of the robot whose footprint should be used.
 * @param obstaclePoses The poses of the footprint.
 * @return A {@link Geometry} that has the shape of the given robot's footprint, placed in each of the the given {@link Pose}s. 
 */
public Geometry[] makeObstacles(int robotID, Pose ... obstaclePoses) {
	ArrayList<Geometry> ret = new ArrayList<Geometry>();
	for (Pose p : obstaclePoses) {
		GeometryFactory gf = new GeometryFactory();
		Coordinate[] footprint = this.getFootprint(robotID);
		Coordinate[] newFoot = new Coordinate[footprint.length+1];
		for (int j = 0; j < footprint.length; j++) {
			newFoot[j] = footprint[j];
		}
		newFoot[footprint.length] = footprint[0];
		Geometry obstacle = gf.createPolygon(newFoot);
		AffineTransformation at = new AffineTransformation();
		at.rotate(p.getTheta());
		at.translate(p.getX(), p.getY());
		obstacle = at.transform(obstacle);
		ret.add(obstacle);
		metaCSPLogger.fine("Made obstacle for Robot" + robotID + " in pose " + p);
	}
	return ret.toArray(new Geometry[ret.size()]);
}
 
Example #12
Source Project: jts   Author: metteo   File: BufferFunctions.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Geometry buildCurveSet(Geometry g, double dist, BufferParameters bufParams)
{
  // --- now construct curve
  OffsetCurveBuilder ocb = new OffsetCurveBuilder(
      g.getFactory().getPrecisionModel(),
      bufParams);
  OffsetCurveSetBuilder ocsb = new OffsetCurveSetBuilder(g, dist, ocb);
  List curves = ocsb.getCurves();
  
  List lines = new ArrayList();
  for (Iterator i = curves.iterator(); i.hasNext(); ) {
  	SegmentString ss = (SegmentString) i.next();
  	Coordinate[] pts = ss.getCoordinates();
  	lines.add(g.getFactory().createLineString(pts));
  }
  Geometry curve = g.getFactory().buildGeometry(lines);
  return curve;
}
 
Example #13
Source Project: gama   Author: gama-platform   File: Graphs.java    License: GNU General Public License v3.0 5 votes vote down vote up
static boolean lineInter(final Coordinate[] coord1, final Coordinate[] coord2) {
	int nb = 0;
	for (int i = 0; i < 3; i++) {
		final Coordinate c1 = coord1[i];
		for (int j = 0; j < 3; j++) {
			final Coordinate c2 = coord2[j];
			if (c1.x == c2.x && c1.y == c2.y) {
				nb++;
			}
		}
	}
	return nb == 2;
}
 
Example #14
Source Project: gama   Author: gama-platform   File: GamaKmlExport.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void fillPoint(final de.micromata.opengis.kml.v_2_2_0.Point kmlpoint, final Point point,
		final double height) {
	final Coordinate pos = point.getCoordinate();
	if (height > 0.0) {
		kmlpoint.setExtrude(true);
		kmlpoint.setAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND);
		kmlpoint.addToCoordinates(pos.x, pos.y, height);
	} else {
		kmlpoint.addToCoordinates(pos.x, pos.y);
	}
}
 
Example #15
Source Project: jts   Author: metteo   File: HCoordinateTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test(expected = NotRepresentableException.class)
public void testNoIntersection() throws NotRepresentableException {
	//y = 2
	Coordinate p1 = new Coordinate(1,2);
	Coordinate p2 = new Coordinate(6,2);
	
	//y = 1
	Coordinate q1 = new Coordinate(1,1);
	Coordinate q2 = new Coordinate(2,1);
	
	//parallel lines, exception expected
	HCoordinate.intersection(p1, p2, q1, q2);
}
 
Example #16
Source Project: jts   Author: metteo   File: RobustLineIntersectorTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testCollinear2() {
  RobustLineIntersector i = new RobustLineIntersector();
  Coordinate p1 = new Coordinate(10, 10);
  Coordinate p2 = new Coordinate(20, 10);
  Coordinate q1 = new Coordinate(20, 10);
  Coordinate q2 = new Coordinate(30, 10);
  i.computeIntersection(p1, p2, q1, q2);
  assertEquals(RobustLineIntersector.POINT_INTERSECTION, i.getIntersectionNum());
  assertTrue(!i.isProper());
  assertTrue(i.hasIntersection());
}
 
Example #17
Source Project: coordination_oru   Author: FedericoPecora   File: SplineFactory.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a Catmull-Rom spline based on the given control points.
 * The generated curve starts in the first control point and ends
 * in the last control point.
 * In addition, the curve intersects all the control points.
 * 
 * @param controlPoints  Control points of spline.
 * @param nParts Number of parts to divide each leg into.
 * @return A Catmull-Rom spline based on the given control points.
 */
public static Spline3D createCatmullRom (Coordinate[] controlPoints, int nParts) {
	double[] cPoints = new double[controlPoints.length*3];
	int counter = 0;
	for (int i = 0; i < controlPoints.length; i++) {
		cPoints[counter] = controlPoints[i].x;
		cPoints[counter+1] = controlPoints[i].y;
		cPoints[counter+2] = controlPoints[i].z;
		counter+=3;
	}
	return new Spline3D(new CatmullRomSpline (cPoints, nParts++).generate(), controlPoints, Spline3D.Type.SPLINE_CATMULL_ROM);
}
 
Example #18
Source Project: jts   Author: metteo   File: KdTree.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Converts a collection of {@link KdNode}s 
 * to an array of {@link Coordinate}s,
 * specifying whether repeated nodes should be represented
 * by multiple coordinates.
 * 
 * @param kdnodes a collection of nodes
 * @param includeRepeated true if repeated nodes should 
 *   be included multiple times
 * @return an array of the coordinates represented by the nodes
 */
public static Coordinate[] toCoordinates(Collection kdnodes, boolean includeRepeated) {
  CoordinateList coord = new CoordinateList();
  for (Iterator it = kdnodes.iterator(); it.hasNext();) {
    KdNode node = (KdNode) it.next();
    int count = includeRepeated ? node.getCount() : 1;
    for (int i = 0; i < count; i++) {
     coord.add(node.getCoordinate(), true);
    }
  }
  return coord.toCoordinateArray();
}
 
Example #19
Source Project: OpenMapKitAndroid   Author: posm   File: JTSModel.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Envelope createTapEnvelope(Coordinate coord, double lat, double lng, float zoom) {
    Envelope envelope = new Envelope(coord);

    // Creating a reasonably sized envelope around the tap location.
    // Tweak the TAP_PIXEL_TOLERANCE to get a better sized box for your needs.
    double degreesLngPerPixel = degreesLngPerPixel(zoom);
    double deltaX = degreesLngPerPixel * TAP_PIXEL_TOLERANCE;
    double deltaY = scaledLatDeltaForMercator(deltaX, lat);
    envelope.expandBy(deltaX, deltaY);
    return envelope;
}
 
Example #20
Source Project: Elasticsearch   Author: baidu   File: ShapeBuilder.java    License: Apache License 2.0 5 votes vote down vote up
protected static Coordinate shift(Coordinate coordinate, double dateline) {
    if (dateline == 0) {
        return coordinate;
    } else {
        return new Coordinate(-2 * dateline + coordinate.x, coordinate.y);
    }
}
 
Example #21
Source Project: gama   Author: gama-platform   File: GamaSpatialMatrix.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public int manhattanDistanceBetween(final IShape g1, final IShape g2) {

	IGridAgent s1 = g1.getAgent() != null && g1.getAgent().getSpecies() == this.getCellSpecies()
			? (IGridAgent) g1.getAgent() : null;
	IGridAgent s2 = g2.getAgent() != null && g2.getAgent().getSpecies() == this.getCellSpecies()
			? (IGridAgent) g2.getAgent() : null;

	if (s1 == null || s2 == null) {
		ILocation p1 = g1.isPoint() ? g1.getLocation() : null;
		ILocation p2 = g2.isPoint() ? g2.getLocation() : null;
		if (s1 == null) {
			s1 = (IGridAgent) this.getPlaceAt(g1.getLocation());
			if (!s1.covers(g1)) {
				s1 = null;
			}
		}
		if (s2 == null) {
			s2 = (IGridAgent) this.getPlaceAt(g2.getLocation());
			if (!s2.covers(g2)) {
				s2 = null;
			}
		}
		final Coordinate[] coord = new DistanceOp(g1.getInnerGeometry(), g2.getInnerGeometry()).nearestPoints();
		if (s1 == null) {
			p1 = new GamaPoint(coord[0]);
			s1 = (IGridAgent) this.getPlaceAt(p1);
		}
		if (s2 == null) {
			p2 = new GamaPoint(coord[1]);
			s2 = (IGridAgent) this.getPlaceAt(p2);
		}
	}

	final int dx = Math.abs(s1.getX() - s2.getX());
	final int dy = Math.abs(s1.getY() - s2.getY());
	if (usesVN) { return dx + dy; }
	return Math.max(dx, dy);
}
 
Example #22
Source Project: coordination_oru   Author: FedericoPecora   File: BrowserVisualization.java    License: GNU General Public License v3.0 5 votes vote down vote up
private String geometryToJSONString(String name, Geometry geom, String color, long age, boolean filled, String extraData) {
	String ret = "{ \"name\" : \"" + name + "\", \"color\" : \"" + color + "\", ";
	if (age > 0) ret += " \"age\" : " + age + ", ";
	ret += " \"filled\" : " + filled + ", ";
	if (extraData != null && !extraData.trim().equals("")) ret += " \"extraData\" : \"" + extraData + "\", ";		
	ret += "\"coordinates\" : [";
	Coordinate[] coords = geom.getCoordinates();
	for (int i = 0; i < coords.length; i++) {
		ret += "{\"x\" : " + coords[i].x + ", \"y\" : " + coords[i].y + "}";
		if (i < coords.length-1) ret += ", ";
	}
	ret += "]}";
	return ret;
}
 
Example #23
@Test
public void readGeometry() throws LayerException {
	GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
	LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 0),
			new Coordinate(1, 1), new Coordinate(0, 1), new Coordinate(0, 0), });
	Polygon p = factory.createPolygon(shell, null);
	MultiPolygon expected = factory.createMultiPolygon(new Polygon[] { p });
	Assert.assertTrue(((CustomBean) layer.read("1")).getGeometry().equalsExact(expected));
}
 
Example #24
Source Project: jts   Author: metteo   File: CGAlgorithms.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Computes the length of a linestring specified by a sequence of points.
 * 
 * @param pts
 *          the points specifying the linestring
 * @return the length of the linestring
 */
public static double length(CoordinateSequence pts)
{
  // optimized for processing CoordinateSequences
  int n = pts.size();
  if (n <= 1)
    return 0.0;

  double len = 0.0;

  Coordinate p = new Coordinate();
  pts.getCoordinate(0, p);
  double x0 = p.x;
  double y0 = p.y;

  for (int i = 1; i < n; i++) {
    pts.getCoordinate(i, p);
    double x1 = p.x;
    double y1 = p.y;
    double dx = x1 - x0;
    double dy = y1 - y0;

    len += Math.sqrt(dx * dx + dy * dy);

    x0 = x1;
    y0 = y1;
  }
  return len;
}
 
Example #25
Source Project: jts   Author: metteo   File: CGAlgorithmsTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testDistancePointLinePerpendicular() {
  assertEquals(0.5, CGAlgorithms.distancePointLinePerpendicular(
      new Coordinate(0.5, 0.5), new Coordinate(0,0), new Coordinate(1,0)), 0.000001);
  assertEquals(0.5, CGAlgorithms.distancePointLinePerpendicular(
      new Coordinate(3.5, 0.5), new Coordinate(0,0), new Coordinate(1,0)), 0.000001);
  assertEquals(0.707106, CGAlgorithms.distancePointLinePerpendicular(
      new Coordinate(1,0), new Coordinate(0,0), new Coordinate(1,1)), 0.000001);
}
 
Example #26
Source Project: jts   Author: metteo   File: MiscellaneousTest2.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testUniqueCoordinateArrayFilter() throws Exception {
  Geometry g = reader.read(
        "MULTIPOINT(10 10, 20 20, 30 30, 20 20, 10 10)");
  UniqueCoordinateArrayFilter f = new UniqueCoordinateArrayFilter();
  g.apply(f);
  assertEquals(3, f.getCoordinates().length);
  assertEquals(new Coordinate(10, 10), f.getCoordinates()[0]);
  assertEquals(new Coordinate(20, 20), f.getCoordinates()[1]);
  assertEquals(new Coordinate(30, 30), f.getCoordinates()[2]);
}
 
Example #27
Source Project: jts   Author: metteo   File: BoxBandTool.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
protected Shape getShape()
{
  if (zoomBoxEnd == null) return null;
  
  Envelope envModel = getEnvelope();
  
  Point2D base = toView(new Coordinate(envModel.getMinX(), envModel.getMaxY()));
  double width = toView(envModel.getWidth());
  double height = toView(envModel.getHeight());
  return new Rectangle2D.Double(base.getX(), base.getY(), width, height);
}
 
Example #28
Source Project: jts   Author: metteo   File: PreparedPolygonIntersectsStressTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void run(int nPts)
  {
//  	Geometry poly = createCircle(new Coordinate(0, 0), 100, nPts);
  	Geometry poly = createSineStar(new Coordinate(0, 0), 100, nPts);
  	System.out.println(poly);
  	
    System.out.println();
    //System.out.println("Running with " + nPts + " points");
    test(poly);
  }
 
Example #29
Source Project: jts   Author: metteo   File: ConvexHullTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testAllIdenticalPoints() throws Exception {
  Coordinate[] pts = new Coordinate[100];
  for (int i = 0; i < 100; i++)
    pts[i] = new Coordinate(0,0);
  ConvexHull ch = new ConvexHull(pts, geometryFactory);
  Geometry actualGeometry = ch.getConvexHull();
  Geometry expectedGeometry = reader.read("POINT (0 0)");
  assertTrue(expectedGeometry.equalsExact(actualGeometry));
}
 
Example #30
Source Project: jts   Author: metteo   File: SegmentPointComparatorTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
private void checkNodePosition(int octant,
    double x0, double y0,
  double x1, double y1,
  int expectedPositionValue
  )
{
  int posValue = SegmentPointComparator.compare(octant,
      new Coordinate(x0, y0),
      new Coordinate(x1, y1)
      );
  assertTrue(posValue == expectedPositionValue);
}