public override GeoPoint visitPoint(GeoPoint p) { return(new GeoPoint(trans.Transform(p.ToDoubleArray()))); #if TODO p.set(p * mat); p.setDim(3); return(true); #endif }
static void bufferPolygons(GeoShape shape, double b, out GeoPartList output) { foreach (GeoPointList i in shape.getParts()) { GeoPointList part = i; if (part.Count < 3) { continue; } GeoPointList new_part; // first build the buffered line segments: SegmentList segments; foreach (GeoPoint j in part) { Vector3D p0 = j; Vector3D p1 = (j + 1) != part.end() ? *(j + 1) : *part.begin(); Vector3D d = p1 - p0; d.Normalize(); Vector3D b0 = new Vector3D(p0.X + b * d.Y, p0.Y - b * d.X, p1.z()); Vector3D b1 = new Vector3D(p1.X + b * d.Y, p1.Y - b * d.X, p1.z()); segments.Add(new Segment(b0, b1)); } // then intersect each pair of segments to find the new verts: foreach (Segment k in segments) { Segment s0 = k; Segment s1 = (k + 1) != segments.end() ? *(k + 1) : *segments.begin(); Vector3D isect; if (getLineIntersection(s0, s1, isect)) { GeoPoint r = new GeoPoint(isect, part[0].getSRS()); r.setDim(part[0].getDim()); new_part.Add(r); } } if (new_part.Count > 2) { output.Add(new_part); } } }
static void bufferLinesToLines(GeoShape input, double b, GeoShape output) { // buffering lines turns them into polygons foreach (GeoPointList i in input.getParts()) { GeoPointList part = i; if (part.Count < 2) { continue; } GeoPointList new_part; // collect all the shifted segments: SegmentList segments; foreach (GeoPoint j in part) { Vector3D p0 = j; Vector3D p1 = *(j + 1); Vector3D d = p1 - p0; d.Normalize(); Vector3D b0 = new Vector3D(p0.X + b * d.Y, p0.Y - b * d.X, p1.Z); Vector3D b1 = new Vector3D(p1.X + b * d.Y, p1.Y - b * d.X, p1.Z); segments.Add(new Segment(b0, b1)); } // then intersect each pair of shifted segments to find the new verts: foreach (Segment k in segments) { Segment s0 = k; Segment s1 = *(k + 1); //(k+1) != segments.end()? *(k+1) : *segments.begin(); if (k == segments.begin()) { GeoPoint first = new GeoPoint(s0.p0, part[0].getSRS()); first.setDim(part[0].getDim()); new_part.Add(first); } Vector3D isect; if (getLineIntersection(s0, s1, out isect)) { GeoPoint r = new GeoPoint(isect, part[0].getSRS()); r.setDim(part[0].getDim()); new_part.Add(r); } if (k == segments.end() - 2) { GeoPoint last = new GeoPoint(s1.p1, part[0].getSRS()); last.setDim(part[0].getDim()); new_part.Add(last); } } if (new_part.Count > 1) { output.getParts().Add(new_part); } } }
static void bufferLinesToPolygons(GeoShape input, double b, GeoShape output) { // buffering lines turns them into polygons foreach (GeoPointList i in input.getParts()) { GeoPointList part = i; if (part.Count < 2) { continue; } GeoPointList new_part; // collect segments in one direction and then the other. SegmentList segments; foreach (GeoPoint j in part) { Vector3D p0 = j; Vector3D p1 = *(j + 1); Vector3D d = p1 - p0; d.Normalize(); Vector3D b0 = new Vector3D(p0.X + b * d.Y, p0.Y - b * d.X, p1.Z); Vector3D b1 = new Vector3D(p1.X + b * d.Y, p1.Y - b * d.X, p1.Z); segments.Add(new Segment(b0, b1)); // after the last seg, add an end-cap: if (j == part.end() - 2) { Vector3D b2 = new Vector3D(p1.X - b * d.Y, p1.Y + b * d.X, p1.Z); segments.Add(new Segment(b1, b2)); } } // now back the other way: foreach (GeoPoint j in part) //TODO IS IN REVERSE !! { Vector3D p0 = j; Vector3D p1 = *(j + 1); Vector3D d = p1 - p0; d.Normalize(); Vector3D b0 = new Vector3D(p0.X + b * d.Y, p0.Y - b * d.X, p1.Z); Vector3D b1 = new Vector3D(p1.X + b * d.Y, p1.Y - b * d.X, p1.Z); segments.Add(new Segment(b0, b1)); // after the last seg, add an end-cap: if (j == part.rend() - 2) { Vector3D b2 = new Vector3D(p1.X - b * d.Y, p1.Y + b * d.X, p1.z()); segments.Add(new Segment(b1, b2)); } } // then intersect each pair of segments to find the new verts: foreach (Segment k in segments) { Segment s0 = k; Segment s1 = (k + 1) != segments.end() ? *(k + 1) : *segments.begin(); Vector3D isect; if (getLineIntersection(s0, s1, out isect)) { GeoPoint r = new GeoPoint(isect, part[0].getSRS()); r.setDim(part[0].getDim()); new_part.Add(r); } } if (new_part.Count > 2) { output.getParts().Add(new_part); } } }
public bool visitPoint(GeoPoint p) { //p.setSpatialReference (p * mat); p.setDim(3); return(true); }