All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vividsolutions.jtsexample.geom.ConstructionExample Maven / Gradle / Ivy

Go to download

The JTS Topology Suite is an API for modelling and manipulating 2-dimensional linear geometry. It provides numerous geometric predicates and functions. JTS conforms to the Simple Features Specification for SQL published by the Open GIS Consortium.

There is a newer version: 1.13
Show newest version
package com.vividsolutions.jtsexample.geom;

import com.vividsolutions.jts.geom.*;

/**
 * Examples of constructing Geometries programmatically.
 * 

* The Best Practice moral here is: * * Use the GeometryFactory to construct Geometries whenever possible. * * This has several advantages: *

    *
  1. Simplifies your code *
  2. allows you to take advantage of convenience methods provided by GeometryFactory *
  3. Insulates your code from changes in the signature of JTS constructors *
* * @version 1.7 */ public class ConstructionExample { public static void main(String[] args) throws Exception { // create a factory using default values (e.g. floating precision) GeometryFactory fact = new GeometryFactory(); Point p1 = fact.createPoint(new Coordinate(0,0)); System.out.println(p1); Point p2 = fact.createPoint(new Coordinate(1,1)); System.out.println(p2); MultiPoint mpt = fact.createMultiPoint(new Coordinate[] { new Coordinate(0,0), new Coordinate(1,1) } ); System.out.println(mpt); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy