public static SqlGeometry STShift(SqlGeometry g, double xShift, double yShift) { var sqlGeometryBuilder = new SqlGeometryBuilder(); var shiftGeometrySink = new ShiftGeometrySink(xShift, yShift, sqlGeometryBuilder); g.Populate(shiftGeometrySink); return(sqlGeometryBuilder.ConstructedGeometry); }
/// <summary> /// Shift the input Geometry x and y co-ordinate by specified amount /// Make our ShiftGeometrySink into a function call by hooking it into a simple pipeline. /// </summary> /// <param name="geometry">Input Geometry</param> /// <param name="xShift">X value to shift</param> /// <param name="yShift">Y value to shift</param> /// <returns>Shifted Geometry</returns> public static SqlGeometry ShiftGeometry(SqlGeometry geometry, double xShift, double yShift) { // create a sink that will create a geometry instance var geometryBuilder = new SqlGeometryBuilder(); // create a sink to do the shift and plug it in to the builder var geomSink = new ShiftGeometrySink(xShift, yShift, geometryBuilder); // plug our sink into the geometry instance and run the pipeline geometry.Populate(geomSink); // the end of our pipeline is now populated with the shifted geometry instance return(geometryBuilder.ConstructedGeometry); }