Package chunmap.model.relate.relateop

Source Code of chunmap.model.relate.relateop.Point_PolygonTest

/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
*     2010-05-05  Jed Young  Creation
*/
package chunmap.model.relate.relateop;

import static org.junit.Assert.*;

import org.junit.Test;

import chunmap.model.geom.GeoPoint;
import chunmap.model.geom.Geometry;
import chunmap.model.geom.Polygon;
import chunmap.model.geom.WktReader;
import chunmap.model.relate.ComputeImFactory;
import chunmap.model.relate.IntersectionMatrix;

public class Point_PolygonTest {

  @Test
  public void testGetIM() {
    WktReader wkt = new WktReader();
    Geometry g = wkt.read("POLYGON((1 2,3 1,4 0,3 -2,0 0,1 2))");
    Polygon pg = (Polygon) g;
    GeoPoint p1 = new GeoPoint(1, 0);
    GeoPoint p2 = new GeoPoint(2, 2);

    IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(p1, pg).getIM();
    IntersectionMatrix rt2 = ComputeImFactory.getInstance().getImComputer(p2, pg).getIM();

    assertTrue(rt.match(IntersectionMatrix.WithinsPattern));
    assertFalse(rt2.match(IntersectionMatrix.WithinsPattern));
    assertTrue(rt2.match(IntersectionMatrix.DisjointPattern));

  }

  @Test
  public void testGetIM2() {
    WktReader wkt = new WktReader();
    Geometry g = wkt
        .read("POLYGON((-5 -8,10 -20,20 15,-10 10,-5 -8),(1 2,3 1,4 0,3 -2,0 0,1 2))");
    Polygon pg = (Polygon) g;
    GeoPoint p1 = new GeoPoint(1, 0);
    GeoPoint p2 = new GeoPoint(2, 2);
    GeoPoint p3 = new GeoPoint(100, 2);

    IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(p1, pg).getIM();
    IntersectionMatrix rt2 = ComputeImFactory.getInstance().getImComputer(p2, pg).getIM();
    IntersectionMatrix rt3 = ComputeImFactory.getInstance().getImComputer(p3, pg).getIM();

    assertTrue(rt.match(IntersectionMatrix.DisjointPattern));
    assertTrue(rt2.match(IntersectionMatrix.WithinsPattern));
    assertTrue(rt3.match(IntersectionMatrix.DisjointPattern));

  }

}
TOP

Related Classes of chunmap.model.relate.relateop.Point_PolygonTest

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.