/// <summary> /// Writes three geometries to an svg file /// </summary> /// <param name="filename">The path of the svg file.</param> /// <param name="a">The A geometry</param> /// <param name="b">The B geometry</param> /// <param name="c">The C geometry</param> public void DisplayTest(string filename, Geometry a, Geometry b, Geometry c) { Geotools.Geometries.PrecisionModel pm = new Geotools.Geometries.PrecisionModel(1, 0, 0); GeometryFactory fact = new GeometryFactory(pm, 0); GeometrySVGWriter svgWriter = new GeometrySVGWriter(fact.PrecisionModel); StreamWriter sw = new StreamWriter(filename); GeometryCollection geomCollection= fact.CreateGeometryCollection(new Geometry[]{a,b,c}); double minx, miny, maxx, maxy; geomCollection.Extent2D(out minx, out miny, out maxx, out maxy); sw.WriteLine(String.Format("<svg viewBox=\"{0} {1} {2} {3}\">",minx,miny,maxx,maxy*1.2)); svgWriter.Write(a,sw,"fill-rule:evenodd;","fill:none;stroke:blue;stroke-width:1;fill-opacity:0.2"); svgWriter.Write(b,sw,"fill-rule:evenodd;","fill:none;stroke:red;stroke-width:1;fill-opacity:0.2"); svgWriter.Write(c,sw,"fill-rule:evenodd;","fill:yellow;stroke:green;stroke-width:2;fill-opacity:0.5;stroke-dasharray:2,2"); sw.WriteLine("</svg>"); sw.Close(); }
private GeometryCollection CreateCollection4() { //this is used to prevent having to rewrite this code over & over //create a new coordinate Coordinate coordinate = new Coordinate(); //create a new point GeometryFactory gf = new GeometryFactory(_precMod, _sRID); Point point = gf.CreatePoint(coordinate); //create a new geometries array Geometry[] geom = new Geometry[10]; int c = 0; //fill with points for(int i = 9; i < 19 ; i++) { //if this isn't here the coordinates for all the points are reset every time the coordinate is reset coordinate = new Coordinate(); //make the x coordinate equal to the iterator coordinate.X = (double)i; //make the y coordinate equal to the iterator plus 10 coordinate.Y = (double)i + 10; //create a new point to put in the geometry point = gf.CreatePoint(coordinate); //put the point in the geometies geom[c] = point; c++; } //put the geometries into a geometry collection GeometryCollection geoColl = gf.CreateGeometryCollection(geom); return geoColl; }
private GeometryCollection CreateCollection3() { //create a new geometries array Geometry[] geom = new Geometry[10]; Coordinate coordinate = new Coordinate(); Coordinates coords = new Coordinates(); GeometryFactory gf = new GeometryFactory(_precMod, _sRID); Point point = gf.CreatePoint(coordinate); LineString lineString = gf.CreateLineString(coords); for(int c = 0; c < 5; c++) { for(int i = c; i < c+5; i++) { //if this isn't here the coordinates for all the points are reset every time the coordinate is reset coordinate = new Coordinate(); //make the x coordinate equal to the iterator coordinate.X = (double)i; //make the y coordinate equal to the iterator plus 10 coordinate.Y = (double)i + 10; coords.Add(coordinate); } lineString = gf.CreateLineString(coords); geom[c] = lineString; } for(int i = 5; i < 10; i++) { //if this isn't here the coordinates for all the points are reset every time the coordinate is reset coordinate = new Coordinate(); //make the x coordinate equal to the iterator coordinate.X = (double)i; //make the y coordinate equal to the iterator plus 10 coordinate.Y = (double)i + 10; //create a new point to put in the geometry point = gf.CreatePoint(coordinate); //put the point in the geometies geom[i] = point; } //put the geometries into a geometry collection GeometryCollection geoColl = gf.CreateGeometryCollection(geom); return geoColl; }
public void test_NumPoints() { //create a geomerty collection GeometryCollection geoColl = CreateCollection(); Assertion.AssertEquals("NumPoints-1: ", 10, geoColl.GetNumPoints()); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); geoColl = gf.CreateGeometryCollection(null); Assertion.AssertEquals("NumPoints-2: ", 0, geoColl.GetNumPoints()); //now try it with a different geometry collection geoColl = CreateCollection2(); Assertion.AssertEquals("NumPoints-3: ", 1000, geoColl.GetNumPoints()); //now try it with a mixed geometry collection geoColl = CreateCollection3(); Assertion.AssertEquals("NumPoints-4: ", 130, geoColl.GetNumPoints()); }
public void test_IsEmpty() { //create a geomerty collection GeometryCollection geoColl = CreateCollection(); Assertion.AssertEquals("IsEmpty()-1: ", false, geoColl.IsEmpty()); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); geoColl = gf.CreateGeometryCollection(null); Assertion.AssertEquals("IsEmpty()-2: ", true, geoColl.IsEmpty()); //now try it with a different geometry collection geoColl = CreateCollection2(); Assertion.AssertEquals("IsEmpty()-3: ", false, geoColl.IsEmpty()); //now try it with a mixed geometry collection geoColl = CreateCollection3(); Assertion.AssertEquals("IsEmpty()-4: ", false, geoColl.IsEmpty()); }
public void test_GetBoundaryDimension() { //create a geomerty collection GeometryCollection geoColl = CreateCollection(); Assertion.AssertEquals("GetBoundaryDimension-1: ", -1, geoColl.GetBoundaryDimension()); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); geoColl = gf.CreateGeometryCollection(null); Assertion.AssertEquals("GetBoundaryDimension-2: ", -1, geoColl.GetBoundaryDimension()); //now try it with a different geometry collection geoColl = CreateCollection2(); Assertion.AssertEquals("GetBoundaryDimension-3: ", 0, geoColl.GetBoundaryDimension()); //now try it with a mixed geometry collection geoColl = CreateCollection3(); Assertion.AssertEquals("GetBoundryDimension-4: ", 0, geoColl.GetBoundaryDimension()); }
public void test_EqualExact() { //create a geomerty collection GeometryCollection geoColl1 = CreateCollection(); //create another geometry collection that is null GeometryFactory gf = new GeometryFactory(_precMod, _sRID); GeometryCollection geoColl2 = gf.CreateGeometryCollection(null); //create another geometry collection that is different GeometryCollection geoColl3 = CreateCollection2(); //create another geometry collection that is different GeometryCollection geoColl4 = CreateCollection3(); //create another geometry collection that is the same as the first GeometryCollection geoColl5 = CreateCollection(); Assertion.AssertEquals("Equals-1: ", true , geoColl1.Equals(geoColl5)); Assertion.AssertEquals("Equals-2: ", false, geoColl1.Equals(geoColl2)); Assertion.AssertEquals("Equals-3: ", false, geoColl1.Equals(geoColl3)); Assertion.AssertEquals("Equals-4: ", false, geoColl1.Equals(geoColl4)); }
public void test_Dimension() { //create a geomerty collection GeometryCollection geoColl = CreateCollection(); //returns 0 because a point has a dimension of 0 & that is the largest dimesion in the collection Assertion.AssertEquals("Dimension-1: ", 0, geoColl.GetDimension()); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); geoColl = gf.CreateGeometryCollection(null); //returns -1 because the collection is empty Assertion.AssertEquals("Dimension-2: ", -1, geoColl.GetDimension()); //now try it with a different geometry collection geoColl = CreateCollection2(); //returns 1 because linestring has a dimension of 1 & that is the largest dimension in the collection Assertion.AssertEquals("Dimension-3: ", 1, geoColl.GetDimension()); //returns 1 because linestring has a dimension of 1 & that is the largest dimension in the collection geoColl = CreateCollection3(); Assertion.AssertEquals("Dimension-4: ", 1, geoColl.GetDimension()); }
public void test_Count() { //create a geomerty collection GeometryCollection geoColl = CreateCollection(); Assertion.AssertEquals("Count-1: ", 10, geoColl.Count); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); geoColl = gf.CreateGeometryCollection(null); Assertion.AssertEquals("Count-2: ", 0, geoColl.Count); //now try it with a different geometry collection geoColl = CreateCollection2(); Assertion.AssertEquals("Count-3: ", 10, geoColl.Count); //now try it with a mixed geometry collection geoColl = CreateCollection3(); Assertion.AssertEquals("Count-4: ", 10, geoColl.Count); }
public void test_Coordinates() { //create a geomerty collection GeometryCollection geoColl = CreateCollection(); //this geometry conatins 10 sets of coordinates Assertion.AssertEquals("Coordinates-1: ", 10, geoColl.GetCoordinates().Count); //now try it with a null geometry collection GeometryFactory gf = new GeometryFactory(_precMod, _sRID); geoColl = gf.CreateGeometryCollection(null); Assertion.AssertEquals("Coordinates-2: ", 0, geoColl.GetCoordinates().Count); //now try it with a different geometry collection geoColl = CreateCollection2(); //1000 sets of coordinates Assertion.AssertEquals("Cordinates-3: ", 1000, geoColl.GetCoordinates().Count); //now try it with a mixed geometry collection geoColl = CreateCollection3(); Assertion.AssertEquals("Coordinates-4: ", 130, geoColl.GetCoordinates().Count); }
public void test_CompareToSameClass() { //create a geometry collection GeometryCollection geoColl1 = CreateCollection(); //create another geometry collection GeometryCollection geoColl2 = CreateCollection1(); //create another geometry collection GeometryCollection geoColl3 = CreateCollection4(); GeometryFactory gf = new GeometryFactory(_precMod, _sRID); GeometryCollection geoColl4 = gf.CreateGeometryCollection(null); Assertion.AssertEquals("CompareToSameClass1: ", 0, geoColl1.CompareToSameClass(geoColl1)); Assertion.AssertEquals("CompareToSameClass2: ", -1, geoColl1.CompareToSameClass(geoColl3)); Assertion.AssertEquals("CompareToSameClass3: ", 1, geoColl3.CompareToSameClass(geoColl1)); Assertion.AssertEquals("CompareToSameClass4: ", -1, geoColl4.CompareToSameClass(geoColl1)); }