Package com.vividsolutions.jtsexample.geom

Source Code of com.vividsolutions.jtsexample.geom.ConstructionExample

package com.vividsolutions.jtsexample.geom;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.MultiPoint;
import com.vividsolutions.jts.geom.Point;

/**
* Examples of constructing Geometries programmatically.
* <p>
* The Best Practice moral here is:
* <quote>
* Use the GeometryFactory to construct Geometries whenever possible.
* </quote>
* This has several advantages:
* <ol>
* <li>Simplifies your code
* <li>allows you to take advantage of convenience methods provided by GeometryFactory
* <li>Insulates your code from changes in the signature of JTS constructors
* </ol>
*
* @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);

  }
}
TOP

Related Classes of com.vividsolutions.jtsexample.geom.ConstructionExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.