protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint) { // Override the base method and modify the logic for resizing if the shape is the "custom" if (sourceFeature.ColumnValues.ContainsKey("Edit") && sourceFeature.ColumnValues["Edit"] == "rectangle") { PolygonShape polygonShape = sourceFeature.GetShape() as PolygonShape; if (polygonShape != null) { // If the rectangle is horizontal or vertical, it will use the custom method. if (string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText())) { int fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint); PointShape fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]); RectangleShape newRectangleShape = new LineShape(new Vertex[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox(); return(new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues)); } } } return(base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint)); }
protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint) { // Override the base method and modify the logic for resizing if the shape is the "custom" var polygonShape = sourceFeature.GetShape() as PolygonShape; if (polygonShape != null) { // If the rectangle is horizontal or vertical, it will use the custom method. if (string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText())) { var fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint); var fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]); var newRectangleShape = new LineShape(new[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox(); return base.ResizeFeatureCore(new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues), targetControlPoint, targetControlPoint); } } return base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint); }
public static MultilineShape GetDifference(this LineShape masterLine, AreaBaseShape clippingArea) { MultilineShape resultMultiLineShape = new MultilineShape(); var masterGeoLine = SqlGeometry.STGeomFromWKB(new SqlBytes(masterLine.GetWellKnownBinary()), 0); var clippingGeoArea = SqlGeometry.STGeomFromWKB(new SqlBytes(clippingArea.GetWellKnownBinary()), 0); var resultWkb = masterGeoLine.STSymDifference(clippingGeoArea).MakeValid().STAsBinary().Value; var resultFeature = new Feature(resultWkb); var resultShape = resultFeature.GetShape(); if (resultShape is GeometryCollectionShape) { foreach (var line in ((GeometryCollectionShape)resultFeature.GetShape()).Shapes.OfType <LineShape>()) { resultMultiLineShape.Lines.Add(line); } } else if (resultShape is MultilineShape) { foreach (var item in ((MultilineShape)resultShape).Lines) { resultMultiLineShape.Lines.Add(item); } } else if (resultShape is LineShape) { resultMultiLineShape.Lines.Add((LineShape)resultShape); } return(resultMultiLineShape); }