/// <exception cref="org.codehaus.jackson.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool testPolygon()
        {
            bool bAnswer = true;

            com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon();
            polygon.startPath(-97.06138, 32.837);
            polygon.lineTo(-97.06133, 32.836);
            polygon.lineTo(-97.06124, 32.834);
            polygon.lineTo(-97.06127, 32.832);
            polygon.startPath(-97.06326, 32.759);
            polygon.lineTo(-97.06298, 32.755);
            {
                org.codehaus.jackson.JsonParser polygonPathsWgs84Parser = factory.createJsonParser
                                                                              (com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWGS84, polygon
                                                                                                                                    ));
                com.esri.core.geometry.MapGeometry mPolygonWGS84MP = com.esri.core.geometry.GeometryEngine
                                                                     .jsonToGeometry(polygonPathsWgs84Parser);
                NUnit.Framework.Assert.IsTrue(polygon.getPointCount() + 1 == ((com.esri.core.geometry.Polygon
                                                                               )mPolygonWGS84MP.getGeometry()).getPointCount());
                NUnit.Framework.Assert.IsTrue(polygon.getPoint(0).getX() == ((com.esri.core.geometry.Polygon
                                                                              )mPolygonWGS84MP.getGeometry()).getPoint(0).getX());
                NUnit.Framework.Assert.IsTrue(polygon.getPoint(0).getY() == ((com.esri.core.geometry.Polygon
                                                                              )mPolygonWGS84MP.getGeometry()).getPoint(0).getY());
                NUnit.Framework.Assert.IsTrue(polygon.getPathCount() == ((com.esri.core.geometry.Polygon
                                                                          )mPolygonWGS84MP.getGeometry()).getPathCount());
                NUnit.Framework.Assert.IsTrue(polygon.getSegmentCount() + 1 == ((com.esri.core.geometry.Polygon
                                                                                 )mPolygonWGS84MP.getGeometry()).getSegmentCount());
                NUnit.Framework.Assert.IsTrue(polygon.getSegmentCount(0) == ((com.esri.core.geometry.Polygon
                                                                              )mPolygonWGS84MP.getGeometry()).getSegmentCount(0));
                NUnit.Framework.Assert.IsTrue(polygon.getSegmentCount(1) + 1 == ((com.esri.core.geometry.Polygon
                                                                                  )mPolygonWGS84MP.getGeometry()).getSegmentCount(1));
                int lastIndex = polygon.getPointCount() - 1;
                NUnit.Framework.Assert.IsTrue(polygon.getPoint(lastIndex).getX() == ((com.esri.core.geometry.Polygon
                                                                                      )mPolygonWGS84MP.getGeometry()).getPoint(lastIndex).getX());
                NUnit.Framework.Assert.IsTrue(polygon.getPoint(lastIndex).getY() == ((com.esri.core.geometry.Polygon
                                                                                      )mPolygonWGS84MP.getGeometry()).getPoint(lastIndex).getY());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == mPolygonWGS84MP.getSpatialReference
                                                  ().getID());
                if (!checkResultSpatialRef(mPolygonWGS84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                com.esri.core.geometry.Polygon p = new com.esri.core.geometry.Polygon();
                p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z);
                p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
                string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1
                                                                                , p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"rings\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"
                                                       ));
                p.startPath(0, 0);
                p.lineTo(0, 1);
                p.lineTo(4, 4);
                p.startPath(2, 2);
                p.lineTo(3, 3);
                p.lineTo(7, 8);
                p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3);
                p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 7);
                p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 5);
                p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0, 5);
                s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1
                                                                         , p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"rings\":[[[0,0,3,null],[0,1,0,7],[4,4,0,5],[0,0,3,null]],[[2,2,0,null],[3,3,0,null],[7,8,0,5],[2,2,0,null]]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"
                                                       ));
            }
            {
                // Test Import Polygon from Polygon
                string rings = "{\"hasZ\": true, \"rings\" : [ [ [0,0, 5], [0.0, 10.0, 5], [10.0,10.0, 5, 66666], [10.0,0.0, 5] ], [ [12, 12] ],  [ [13 , 17], [13 , 17] ], [ [1.0, 1.0, 5, 66666], [9.0,1.0, 5], [9.0,9.0, 5], [1.0,9.0, 5], [1.0, 1.0, 5] ] ] }";
                com.esri.core.geometry.MapGeometry mapGeometry = com.esri.core.geometry.GeometryEngine
                                                                 .jsonToGeometry(factory.createJsonParser(rings));
                com.esri.core.geometry.Polygon p = (com.esri.core.geometry.Polygon)mapGeometry.getGeometry
                                                       ();
                double area   = p.calculateArea2D();
                double length = p.calculateLength2D();
                NUnit.Framework.Assert.IsTrue(p.getPathCount() == 4);
                int count = p.getPointCount();
                NUnit.Framework.Assert.IsTrue(count == 15);
                NUnit.Framework.Assert.IsTrue(p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                             .Z));
                NUnit.Framework.Assert.IsTrue(!p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                              .M));
            }
            return(bAnswer);
        }
示例#2
0
 public static void testClipAttributes()
 {
     com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal
                                                          .getInstance();
     com.esri.core.geometry.OperatorClip clipOp = (com.esri.core.geometry.OperatorClip
                                                   )engine.getOperator(com.esri.core.geometry.Operator.Type.Clip);
     {
         com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon();
         polygon.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
         polygon.startPath(0, 0);
         polygon.lineTo(30, 30);
         polygon.lineTo(60, 0);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0,
                              0);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0,
                              60);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0,
                              120);
         com.esri.core.geometry.Envelope2D clipper = new com.esri.core.geometry.Envelope2D
                                                         ();
         clipper.setCoords(10, 0, 50, 20);
         com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp
                                                         .execute(polygon, clipper, com.esri.core.geometry.SpatialReference.create(4326),
                                                                  null);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 0, 0) == 100);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 1, 0) == 19.999999999999996);
         // 20.0
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 2, 0) == 20);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 3, 0) == 40);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 4, 0) == 80);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 5, 0) == 100);
     }
     {
         com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon();
         polygon.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
         polygon.startPath(0, 0);
         polygon.lineTo(0, 40);
         polygon.lineTo(20, 40);
         polygon.lineTo(20, 0);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0,
                              0);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0,
                              60);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0,
                              120);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0,
                              180);
         com.esri.core.geometry.Envelope2D clipper = new com.esri.core.geometry.Envelope2D
                                                         ();
         clipper.setCoords(0, 10, 20, 20);
         com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp
                                                         .execute(polygon, clipper, com.esri.core.geometry.SpatialReference.create(4326),
                                                                  null);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 0, 0) == 15);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 1, 0) == 30);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 2, 0) == 150);
         NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 3, 0) == 165);
     }
 }
 public static void testEditShape()
 {
     {
         // std::shared_ptr<Esri_runtimecore::Geometry::Polygon> poly_base_6
         // = std::make_shared<Esri_runtimecore::Geometry::Polygon>();
         // Single part polygon
         com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(14, 15);
         poly.lineTo(10, 11);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.
                                                getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Two part poly
         com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(14, 15);
         poly.lineTo(10, 11);
         poly.startPath(100, 10);
         poly.lineTo(100, 12);
         poly.lineTo(14, 150);
         poly.lineTo(10, 101);
         poly.lineTo(100, 11);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.
                                                getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Single part polyline
         com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(14, 15);
         poly.lineTo(10, 11);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape
                                                 .getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Two part poly
         com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(14, 15);
         poly.lineTo(10, 11);
         poly.startPath(100, 10);
         poly.lineTo(100, 12);
         poly.lineTo(14, 150);
         poly.lineTo(10, 101);
         poly.lineTo(100, 11);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape
                                                 .getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Five part poly. Close one of parts to test if it works.
         com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(14, 15);
         poly.lineTo(10, 11);
         poly.startPath(100, 10);
         poly.lineTo(100, 12);
         poly.lineTo(14, 150);
         poly.lineTo(10, 101);
         poly.lineTo(100, 11);
         poly.startPath(1100, 101);
         poly.lineTo(1300, 132);
         poly.lineTo(144, 150);
         poly.lineTo(106, 1051);
         poly.lineTo(1600, 161);
         poly.startPath(100, 190);
         poly.lineTo(1800, 192);
         poly.lineTo(184, 8150);
         poly.lineTo(1080, 181);
         poly.startPath(1030, 10);
         poly.lineTo(1300, 132);
         poly.lineTo(314, 3150);
         poly.lineTo(310, 1301);
         poly.lineTo(3100, 311);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         editShape.setClosedPath(editShape.getNextPath(editShape.getFirstPath(geom)), true
                                 );
         ((com.esri.core.geometry.MultiPathImpl)poly._getImpl()).closePathWithLine(1);
         com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape
                                                 .getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Test erase
         com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(314, 3150);
         poly.lineTo(310, 1301);
         poly.lineTo(3100, 311);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom   = editShape.addGeometry(poly);
         int vertex = editShape.getFirstVertex(editShape.getFirstPath(geom));
         vertex = editShape.removeVertex(vertex, true);
         vertex = editShape.getNextVertex(vertex);
         editShape.removeVertex(vertex, true);
         com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape
                                                 .getGeometry(geom);
         poly.setEmpty();
         poly.startPath(10, 12);
         poly.lineTo(310, 1301);
         poly.lineTo(3100, 311);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Test erase
         com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
         poly.startPath(10, 10);
         poly.lineTo(10, 12);
         poly.lineTo(314, 3150);
         poly.lineTo(310, 1301);
         poly.lineTo(3100, 311);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom   = editShape.addGeometry(poly);
         int vertex = editShape.getFirstVertex(editShape.getFirstPath(geom));
         vertex = editShape.removeVertex(vertex, true);
         vertex = editShape.getNextVertex(vertex);
         editShape.removeVertex(vertex, true);
         com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.
                                                getGeometry(geom);
         poly.setEmpty();
         poly.startPath(10, 12);
         poly.lineTo(310, 1301);
         poly.lineTo(3100, 311);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Test Filter Close Points
         com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
         poly.startPath(10, 10);
         poly.lineTo(10, 10.001);
         poly.lineTo(10.001, 10);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         editShape.filterClosePoints(0.002, true, false);
         com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.
                                                getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly2.isEmpty());
     }
     {
         // Test Filter Close Points
         com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
         poly.startPath(10, 10);
         poly.lineTo(10, 10.0025);
         poly.lineTo(11.0, 10);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         editShape.filterClosePoints(0.002, true, false);
         com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.
                                                getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(!poly2.isEmpty());
     }
     {
         // Test Filter Close Points
         com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
         poly.startPath(10, 10);
         poly.lineTo(10, 10.001);
         poly.lineTo(11.0, 10);
         com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape
                                                          ();
         int geom = editShape.addGeometry(poly);
         editShape.filterClosePoints(0.002, true, false);
         com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.
                                                getGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly2.isEmpty());
     }
     {
         // Test attribute splitting 1
         com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline();
         polyline.startPath(0, 0);
         polyline.lineTo(1, 1);
         polyline.lineTo(2, 2);
         polyline.lineTo(3, 3);
         polyline.lineTo(4, 4);
         polyline.startPath(5, 5);
         polyline.lineTo(6, 6);
         polyline.lineTo(7, 7);
         polyline.lineTo(8, 8);
         polyline.lineTo(9, 9);
         polyline.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0,
                               4);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0,
                               8);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0,
                               12);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0,
                               16);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 4, 0,
                               20);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 5, 0,
                               22);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 6, 0,
                               26);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 7, 0,
                               30);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 8, 0,
                               34);
         polyline.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 9, 0,
                               38);
         com.esri.core.geometry.EditShape shape = new com.esri.core.geometry.EditShape();
         int geometry = shape.addGeometry(polyline);
         com.esri.core.geometry.AttributeStreamOfInt32 vertex_handles = new com.esri.core.geometry.AttributeStreamOfInt32
                                                                            (0);
         for (int path = shape.getFirstPath(geometry); path != -1; path = shape.getNextPath
                                                                              (path))
         {
             for (int vertex = shape.getFirstVertex(path); vertex != -1; vertex = shape.getNextVertex
                                                                                      (vertex))
             {
                 if (vertex != shape.getLastVertex(path))
                 {
                     vertex_handles.add(vertex);
                 }
             }
         }
         double[] t = new double[1];
         for (int i = 0; i < vertex_handles.size(); i++)
         {
             int vertex = vertex_handles.read(i);
             t[0] = 0.5;
             shape.splitSegment(vertex, t, 1);
         }
         com.esri.core.geometry.Polyline chopped_polyline = (com.esri.core.geometry.Polyline
                                                             )shape.getGeometry(geometry);
         NUnit.Framework.Assert.IsTrue(chopped_polyline.getPointCount() == 18);
         double att_ = 4;
         for (int i_1 = 0; i_1 < 18; i_1++)
         {
             double att = chopped_polyline.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                             .Z, i_1, 0);
             NUnit.Framework.Assert.IsTrue(att == att_);
             att_ += 2;
         }
     }
     {
         // Test attribute splitting 2
         com.esri.core.geometry.Polyline line1 = new com.esri.core.geometry.Polyline();
         com.esri.core.geometry.Polyline line2 = new com.esri.core.geometry.Polyline();
         line1.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
         line2.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
         line1.startPath(0, 0);
         line1.lineTo(10, 10);
         line2.startPath(10, 0);
         line2.lineTo(0, 10);
         line1.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 7);
         line1.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 17
                            );
         line2.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 5);
         line2.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 15
                            );
         com.esri.core.geometry.EditShape shape = new com.esri.core.geometry.EditShape();
         int g1 = shape.addGeometry(line1);
         int g2 = shape.addGeometry(line2);
         com.esri.core.geometry.CrackAndCluster.execute(shape, 0.001, null, true);
         com.esri.core.geometry.Polyline chopped_line1 = (com.esri.core.geometry.Polyline)
                                                         shape.getGeometry(g1);
         com.esri.core.geometry.Polyline chopped_line2 = (com.esri.core.geometry.Polyline)
                                                         shape.getGeometry(g2);
         double att1 = chopped_line1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                       .M, 1, 0);
         double att2 = chopped_line2.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                       .M, 1, 0);
         NUnit.Framework.Assert.IsTrue(att1 == 12);
         NUnit.Framework.Assert.IsTrue(att2 == 10);
     }
     {
         // Test attribute splitting 3
         com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon();
         polygon.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
         polygon.startPath(0, 0);
         polygon.lineTo(0, 10);
         polygon.lineTo(10, 10);
         polygon.lineTo(10, 0);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0,
                              7);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0,
                              17);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0,
                              23);
         polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0,
                              43);
         com.esri.core.geometry.EditShape shape = new com.esri.core.geometry.EditShape();
         int geometry = shape.addGeometry(polygon);
         com.esri.core.geometry.AttributeStreamOfInt32 vertex_handles = new com.esri.core.geometry.AttributeStreamOfInt32
                                                                            (0);
         int start_v = shape.getFirstVertex(shape.getFirstPath(geometry));
         int v       = start_v;
         do
         {
             vertex_handles.add(v);
             v = shape.getNextVertex(v);
         }while (v != start_v);
         double[] t = new double[1];
         for (int i = 0; i < vertex_handles.size(); i++)
         {
             int v1 = vertex_handles.read(i);
             t[0] = 0.5;
             shape.splitSegment(v1, t, 1);
         }
         com.esri.core.geometry.Polygon cut_polygon = (com.esri.core.geometry.Polygon)shape
                                                      .getGeometry(geometry);
         NUnit.Framework.Assert.IsTrue(cut_polygon.getPointCount() == 8);
         com.esri.core.geometry.Point2D pt0 = cut_polygon.getXY(0);
         double a0 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 0, 0);
         NUnit.Framework.Assert.IsTrue(a0 == 25);
         com.esri.core.geometry.Point2D pt1 = cut_polygon.getXY(1);
         double a1 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 1, 0);
         NUnit.Framework.Assert.IsTrue(a1 == 7);
         com.esri.core.geometry.Point2D pt2 = cut_polygon.getXY(2);
         double a2 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 2, 0);
         NUnit.Framework.Assert.IsTrue(a2 == 12);
         com.esri.core.geometry.Point2D pt3 = cut_polygon.getXY(3);
         double a3 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 3, 0);
         NUnit.Framework.Assert.IsTrue(a3 == 17);
         com.esri.core.geometry.Point2D pt4 = cut_polygon.getXY(4);
         double a4 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 4, 0);
         NUnit.Framework.Assert.IsTrue(a4 == 20);
         com.esri.core.geometry.Point2D pt5 = cut_polygon.getXY(5);
         double a5 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 5, 0);
         NUnit.Framework.Assert.IsTrue(a5 == 23);
         com.esri.core.geometry.Point2D pt6 = cut_polygon.getXY(6);
         double a6 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 6, 0);
         NUnit.Framework.Assert.IsTrue(a6 == 33);
         com.esri.core.geometry.Point2D pt7 = cut_polygon.getXY(7);
         double a7 = cut_polygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M, 7, 0);
         NUnit.Framework.Assert.IsTrue(a7 == 43);
     }
 }
示例#4
0
 public virtual void testPolygon()
 {
     com.esri.core.geometry.Polygon mp = new com.esri.core.geometry.Polygon();
     mp.startPath(new com.esri.core.geometry.Point(100, 200));
     mp.lineTo(new com.esri.core.geometry.Point(101, 201));
     mp.lineTo(new com.esri.core.geometry.Point(102, 202));
     NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                    .M));
     mp.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                   .M));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                     .M, 0, 0)));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                     .M, 1, 0)));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                     .M, 2, 0)));
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 1);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 2);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 3);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 0, 0) == 1);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 1, 0) == 2);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 2, 0) == 3);
     NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                    .Z));
     mp.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z);
     NUnit.Framework.Assert.IsTrue(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                   .Z));
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 0, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 1, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 2, 0) == 0);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 11);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0, 21);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0, 31);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 0, 0) == 1);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 1, 0) == 2);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 2, 0) == 3);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 0, 0) == 11);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 1, 0) == 21);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 2, 0) == 31);
     NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                    .ID));
     mp.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID);
     NUnit.Framework.Assert.IsTrue(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                   .ID));
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 0, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 1, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 2, 0) == 0);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 0, -11);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 1, 0, -21);
     mp.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 2, 0, -31);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 0, 0) == 1);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 1, 0) == 2);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .M, 2, 0) == 3);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 0, 0) == 11);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 1, 0) == 21);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 2, 0) == 31);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 0, 0) == -11);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 1, 0) == -21);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 2, 0) == -31);
     mp.dropAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsFalse(mp.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                    .M));
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 0, 0) == 11);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 1, 0) == 21);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .Z, 2, 0) == 31);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 0, 0) == -11);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 1, 0) == -21);
     NUnit.Framework.Assert.IsTrue(mp.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                        .ID, 2, 0) == -31);
     com.esri.core.geometry.Polygon mp1 = new com.esri.core.geometry.Polygon();
     mp.copyTo(mp1);
     NUnit.Framework.Assert.IsFalse(mp1.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                     .M));
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .Z, 0, 0) == 11);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .Z, 1, 0) == 21);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .Z, 2, 0) == 31);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .ID, 0, 0) == -11);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .ID, 1, 0) == -21);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .ID, 2, 0) == -31);
     mp1.dropAllAttributes();
     mp1.mergeVertexDescription(mp.getDescription());
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .Z, 0, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .Z, 1, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .Z, 2, 0) == 0);
     NUnit.Framework.Assert.IsTrue(double.IsNaN(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                      .M, 0, 0)));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                      .M, 1, 0)));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                                      .M, 2, 0)));
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .ID, 0, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .ID, 1, 0) == 0);
     NUnit.Framework.Assert.IsTrue(mp1.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics
                                                         .ID, 2, 0) == 0);
 }