Package chunmap.model.relate.relateop

Source Code of chunmap.model.relate.relateop.Polygon_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.Geometry;
import chunmap.model.geom.Polygon;
import chunmap.model.geom.WktReader;
import chunmap.model.relate.ComputeImFactory;
import chunmap.model.relate.IntersectionMatrix;

public class Polygon_PolygonTest {

  @Test
  public void testGetIM() {
    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;
    Geometry g2 = wkt.read("POLYGON((1 0.5,3 0.5,3.5 0,3 -1,1 0,1 0.5))");
    Polygon pg2 = (Polygon) g2;
    Geometry g3 = wkt.read("POLYGON((4 0.5,6 0.5,6.5 0,6 -1,4 0,4 0.5))");
    Polygon pg3 = (Polygon) g3;

    IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
        pg, pg2).getIM();
    assertTrue(rt.match(IntersectionMatrix.DisjointPattern));

    // IntersectionMatrix rt2 = ComputeIm.getInstance().getIM(pg, pg3);
    Polygon_Polygon l2a = new Polygon_Polygon(pg3, pg);
    IntersectionMatrix rt2 = l2a.getIM();
    assertTrue(rt2.match(IntersectionMatrix.WithinsPattern));
  }

  @Test
  public void testGetIM2() {
    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;
    Geometry g2 = wkt.read("POLYGON((-5 -8,10 -20,20 15,-10 10,-5 -8))");
    Polygon pg2 = (Polygon) g2;
    Geometry g3 = wkt.read("POLYGON((4 0.5,6 0.5,6.5 0,6 -1,4 0,4 0.5))");
    Polygon pg3 = (Polygon) g3;

    IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
        pg, pg2).getIM();
    // Polygon_Polygon l2a1 = new Polygon_Polygon(pg, pg2);
    // IntersectionMatrix rt = l2a1.getIM();
    assertTrue(rt.match(IntersectionMatrix.WithinsPattern));

    IntersectionMatrix rt2 = ComputeImFactory.getInstance().getImComputer(
        pg3, pg2).getIM();
    // Polygon_Polygon l2a = new Polygon_Polygon(pg3, pg2);
    // IntersectionMatrix rt2 = l2a.getIM();
    assertTrue(rt2.match(IntersectionMatrix.WithinsPattern));
  }

  @Test
  public void testGetIM3() {
    WktReader wkt = new WktReader();
    Geometry g = wkt
        .read("POLYGON((-2.639991350383829 -1.7999950537374092,-1.8399918576928131 -1.7999950537374092,-1.8399918576928131 -0.9999955610463935,-2.639991350383829 -0.9999955610463935,-2.639991350383829 -1.7999950537374092))");
    Polygon pg = (Polygon) g;
    Geometry g2 = wkt
        .read("POLYGON((1.0 6.0,5.999998414659173 1.0039816335536662,1.0079632645824341 -3.999993658637697,-3.9999857319385903 0.9880551094385923,1.0 6.0))");
    Polygon pg2 = (Polygon) g2;

    // IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
    // pg, pg2).getIM();
    LinearRing_LinearRing r2r = new LinearRing_LinearRing(pg.getShell(),
        pg2.getShell());
    IntersectionMatrix rt = r2r.getIM();
    assertTrue(!rt.match(IntersectionMatrix.DisjointPattern));
  }

  @Test
  public void testGetIM4() {
    WktReader wkt = new WktReader();
    Geometry g = wkt
        .read("POLYGON((3.3400048574815147 -2.1999948000829175,4.140004350172529 -2.1999948000829175,4.140004350172529 -1.399995307391901,3.3400048574815147 -1.399995307391901,3.3400048574815147 -2.1999948000829175))");
    Polygon pg = (Polygon) g;
    Geometry g2 = wkt
        .read("POLYGON((1.0 6.0,5.999998414659173 1.0039816335536662,1.0079632645824341 -3.999993658637697,-3.9999857319385903 0.9880551094385923,1.0 6.0))");
    Polygon pg2 = (Polygon) g2;

    // IntersectionMatrix rt = ComputeImFactory.getInstance().getImComputer(
    // pg, pg2).getIM();
    LinearRing_LinearRing r2r = new LinearRing_LinearRing(pg.getShell(),
        pg2.getShell());
    IntersectionMatrix rt = r2r.getIM();
    assertTrue(!rt.match(IntersectionMatrix.DisjointPattern));
  }
}
TOP

Related Classes of chunmap.model.relate.relateop.Polygon_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.