protected override Collection<Style> GetStylesCore(FeatureSource featureSource) { // here we generate CustomDotDensityStyle. double totalValue = 0; featureSource.Open(); int featureCount = featureSource.GetCount(); for (int i = 0; i < featureCount; i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue)) { totalValue += columnValue; } } featureSource.Close(); CustomDotDensityStyle dotDensityStyle = new CustomDotDensityStyle(); dotDensityStyle.ColumnName = SelectedColumns[0]; dotDensityStyle.PointToValueRatio = DotDensityValue / (totalValue / featureCount); dotDensityStyle.CustomPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(Opacity, Color), 4); return new Collection<Style>() { dotDensityStyle }; }
protected override Style GetStyleCore(FeatureSource featureSource) { double totalValue = 0; featureSource.Open(); int featureCount = featureSource.GetCount(); for (int i = 0; i < featureCount; i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue); totalValue += columnValue; } featureSource.Close(); double pointToValueRatio = DotDensityValue / (totalValue / featureCount); CustomDotDensityStyle dotDensityStyle = new CustomDotDensityStyle(); dotDensityStyle.ColumnName = SelectedColumns[0]; dotDensityStyle.PointToValueRatio = pointToValueRatio; dotDensityStyle.CustomPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Opacity, Color)), 4); return(dotDensityStyle); }
protected override Collection <Style> GetStylesCore(FeatureSource featureSource) { double totalValue = 0; featureSource.Open(); int featureCount = featureSource.GetCount(); for (int i = 0; i < featureCount; i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue); totalValue += columnValue; } featureSource.Close(); CustomDotDensityStyle dotDensityStyle = new CustomDotDensityStyle(); dotDensityStyle.ColumnName = SelectedColumns[0]; dotDensityStyle.PointToValueRatio = DotDensityValue / (totalValue / featureCount); dotDensityStyle.CustomPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(Opacity, Color), 4); return(new Collection <Style>() { dotDensityStyle }); }
protected override Collection<Style> GetStylesCore(FeatureSource featureSource) { // here we generated a class break style and a text style. Collection<GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(Color, EndColor, classBreakCount, ColorWheelDirection); featureSource.Open(); int featureCount = featureSource.GetCount(); double[] values = new double[featureCount]; for (int i = 0; i < featureCount; i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue)) { values[i] = columnValue; } } featureSource.Close(); ClassBreakStyle classBreakStyle = new ClassBreakStyle(SelectedColumns[0]) { BreakValueInclusion = BreakValueInclusion.IncludeValue }; double[] classBreakValues = GetClusterClassBreaks(values, ClassBreakCount - 1); for (int i = 0; i < classBreakValues.Length; i++) { ClassBreak classBreak = new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(this.Opacity, familyColors[i]), GeoColor.FromHtml("#f05133"), 1)); classBreakStyle.ClassBreaks.Add(classBreak); } return new Collection<Style>() { classBreakStyle, TextStyles.Country1("NAME") }; }
protected override Style GetStyleCore(FeatureSource featureSource) { Collection <GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(Color, EndColor, classBreakCount, ColorWheelDirection); featureSource.Open(); int featureCount = featureSource.GetCount(); double[] values = new double[featureCount]; for (int i = 0; i < featureCount; i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue); values[i] = columnValue; } featureSource.Close(); ClassBreakStyle classBreakStyle = new ClassBreakStyle(SelectedColumns[0]) { BreakValueInclusion = BreakValueInclusion.IncludeValue }; double[] classBreakValues = GetClusterClassBreaks(values, ClassBreaksCount - 1); for (int i = 0; i < classBreakValues.Length; i++) { ClassBreak classBreak = new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(this.Opacity, familyColors[i]), GeoColor.FromHtml("#f05133"), 1)); classBreakStyle.ClassBreaks.Add(classBreak); } return(classBreakStyle); }
public virtual RoadNetwork CreateNetwork(FeatureSource featureSource) { featureSource.Open(); QTreeSpatialIndex qtree = new QTreeSpatialIndex(featureSource.GetBoundingBox()); #if DEBUG long featureCount = featureSource.GetCount(); #endif RoadNetwork roadNetwork = new RoadNetwork(); Collection<Feature> features = featureSource.GetAllFeatures(ReturningColumnsType.NoColumns); featureSource.Close(); Collection<Collection<Feature>> featureGroups = GroupFeatures(features); int done = 0; var tasks = (from items in featureGroups select Task.Factory.StartNew(() => { var clonedFeatureSource = featureSource.CloneDeep(); clonedFeatureSource.Open(); foreach (var feature in items) { Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature); // Get the lineshape of the processing feature. foreach (LineShape processingLineShape in processingLineShapes) { BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[0]); BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]); } done++; Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, done)); } })).ToArray(); //foreach (Feature feature in features) //{ // Task.Factory.StartNew(() => // { // Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature); // // Get the lineshape of the processing feature. // foreach (LineShape processingLineShape in processingLineShapes) // { // BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[0]); // BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]); // } // } // ); Task.WaitAll(tasks); #if DEBUG #endif //} //featureSource.Close(); return roadNetwork; }
public virtual RoadNetwork CreateNetwork(FeatureSource featureSource) { featureSource.Open(); QTreeSpatialIndex qtree = new QTreeSpatialIndex(featureSource.GetBoundingBox()); #if DEBUG long featureCount = featureSource.GetCount(); #endif RoadNetwork roadNetwork = new RoadNetwork(); Collection <Feature> features = featureSource.GetAllFeatures(ReturningColumnsType.NoColumns); featureSource.Close(); Collection <Collection <Feature> > featureGroups = GroupFeatures(features); int done = 0; var tasks = (from items in featureGroups select Task.Factory.StartNew(() => { var clonedFeatureSource = featureSource.CloneDeep(); clonedFeatureSource.Open(); foreach (var feature in items) { Collection <LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature); // Get the lineshape of the processing feature. foreach (LineShape processingLineShape in processingLineShapes) { BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[0]); BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]); } done++; Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, done)); } })).ToArray(); //foreach (Feature feature in features) //{ // Task.Factory.StartNew(() => // { // Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature); // // Get the lineshape of the processing feature. // foreach (LineShape processingLineShape in processingLineShapes) // { // BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[0]); // BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]); // } // } // ); Task.WaitAll(tasks); #if DEBUG #endif //} //featureSource.Close(); return(roadNetwork); }
protected override Collection <Style> GetStylesCore(FeatureSource featureSource) { // here we generate a ValueCircle Style. double minValue = double.MaxValue; double maxValue = double.MinValue; featureSource.Open(); for (int i = 0; i < featureSource.GetCount(); i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue)) { if (columnValue < minValue) { minValue = columnValue; } else if (columnValue > maxValue) { maxValue = columnValue; } } } featureSource.Close(); ValueCircleStyle valueCircleStyle = new ValueCircleStyle(); valueCircleStyle.ColumnName = SelectedColumns[0]; valueCircleStyle.DrawingRadiusRatio = radiusRatio; valueCircleStyle.MinValidValue = minValue; valueCircleStyle.MaxValidValue = maxValue; valueCircleStyle.MinCircleAreaInDefaultZoomLevel = 80; valueCircleStyle.MaxCircleAreaInDefaultZoomLevel = 10000; valueCircleStyle.InnerColor = GeoColor.FromArgb(this.Opacity, Color); valueCircleStyle.OuterColor = GeoColor.SimpleColors.White; return(new Collection <Style>() { valueCircleStyle }); }
protected override Collection <Style> GetStylesCore(FeatureSource featureSource) { // here we generated a class break style and a text style. Collection <GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(Color, EndColor, classBreakCount, ColorWheelDirection); featureSource.Open(); int featureCount = featureSource.GetCount(); double[] values = new double[featureCount]; for (int i = 0; i < featureCount; i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue)) { values[i] = columnValue; } } featureSource.Close(); ClassBreakStyle classBreakStyle = new ClassBreakStyle(SelectedColumns[0]) { BreakValueInclusion = BreakValueInclusion.IncludeValue }; double[] classBreakValues = GetClusterClassBreaks(values, ClassBreakCount - 1); for (int i = 0; i < classBreakValues.Length; i++) { ClassBreak classBreak = new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(this.Opacity, familyColors[i]), GeoColor.FromHtml("#f05133"), 1)); classBreakStyle.ClassBreaks.Add(classBreak); } return(new Collection <Style>() { classBreakStyle, TextStyles.CreateSimpleTextStyle("NAME", "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, GeoColor.StandardColors.White, 3) }); }
protected override Collection<Style> GetStylesCore(FeatureSource featureSource) { // here we generate a ValueCircle Style. double minValue = double.MaxValue; double maxValue = double.MinValue; featureSource.Open(); for (int i = 0; i < featureSource.GetCount(); i++) { Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns); double columnValue; if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue)) { if (columnValue < minValue) { minValue = columnValue; } else if (columnValue > maxValue) { maxValue = columnValue; } } } featureSource.Close(); ValueCircleStyle valueCircleStyle = new ValueCircleStyle(); valueCircleStyle.ColumnName = SelectedColumns[0]; valueCircleStyle.DrawingRadiusRatio = radiusRatio; valueCircleStyle.MinValidValue = minValue; valueCircleStyle.MaxValidValue = maxValue; valueCircleStyle.MinCircleAreaInDefaultZoomLevel = 80; valueCircleStyle.MaxCircleAreaInDefaultZoomLevel = 10000; valueCircleStyle.InnerColor = GeoColor.FromArgb(this.Opacity, Color); valueCircleStyle.OuterColor = GeoColor.SimpleColors.White; return new Collection<Style>(){valueCircleStyle}; }
public virtual void ImportData(FeatureSource featureSourceForRead, FeatureSource featureSourceForSave) { bool readCompleted = false; featureSourceForRead.Open(); featureSourceForSave.Open(); #if DEBUG long featureCount = featureSourceForRead.GetCount(); #endif Collection <Feature> features = featureSourceForRead.GetAllFeatures(ReturningColumnsType.AllColumns); Collection <Collection <Feature> > featureGroups = GroupFeatures(features); var writeTasks = (from items in featureGroups select Task.Factory.StartNew(() => WriteFeaturesIntoQueue(items, featureSourceForRead))).ToArray(); var readTask = Task.Factory.StartNew(() => { while (!readCompleted || queue.Count > 0) { while (queue.Count > 0) { Collection <Feature> lineFeatures = queue.Dequeue(); SaveFeatures(lineFeatures, featureSourceForSave); } } }); Task.WaitAll(writeTasks); readCompleted = true; Task.WaitAny(readTask); #region Old version //foreach (Feature feature in features) //{ // Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature); // // Get the lineshape of the processing feature. // foreach (LineShape processingLineShape in processingLineShapes) // { // // Define a variable to save the points where the adjacent lines intersect with current processing line. // Collection<PointShape> crossingPoints = new Collection<PointShape>(); // // Get all the lines in current processing shape bounds. // Collection<Feature> adjacentFeatures = featureSourceForRead.GetFeaturesInsideBoundingBox(processingLineShape.GetBoundingBox(), ReturningColumnsType.NoColumns); // // Loop and see if the queried shape is intersected with processing shape. // foreach (Feature adjacentFeature in adjacentFeatures) // { // LineBaseShape adjacentLineShape = adjacentFeature.GetShape() as LineBaseShape; // MultipointShape tempCrossingPoints = processingLineShape.GetCrossing(adjacentLineShape); // // The queried shape is intersected with processing shape. // foreach (PointShape point in tempCrossingPoints.Points) // { // bool hasAdded = false; // foreach (var item in crossingPoints) // { // if (point.X == item.X && point.Y == item.Y) // { // hasAdded = true; // break; // } // } // if (!hasAdded) // { // crossingPoints.Add(point); // } // } // } // // Order the crossing points following the sequence of line vertex. // Collection<FlagedVertex> vertecesOfNewLine = GeometryHelper.AddCrossingPointToLine(processingLineShape, crossingPoints); // // Split current processing lineshape into segments. // featureSourceForSave.BeginTransaction(); // Collection<Vertex> verteces = new Collection<Vertex>(); // foreach (var vertex in vertecesOfNewLine) // { // verteces.Add(vertex.Vertex); // if (vertex.Flag) // { // if (verteces.Count >= 2) // { // LineShape segment = new LineShape(verteces); // featureSourceForSave.AddFeature(new Feature(segment, feature.ColumnValues)); // verteces.RemoveAt(0); // } // } // } // featureSourceForSave.CommitTransaction(); // } //#if DEBUG //Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, featureCount)); //#endif //} #endregion featureSourceForRead.Close(); featureSourceForSave.Close(); }
public virtual void ImportData(FeatureSource featureSourceForRead, FeatureSource featureSourceForSave) { bool readCompleted = false; featureSourceForRead.Open(); featureSourceForSave.Open(); #if DEBUG long featureCount = featureSourceForRead.GetCount(); #endif Collection<Feature> features = featureSourceForRead.GetAllFeatures(ReturningColumnsType.AllColumns); Collection<Collection<Feature>> featureGroups = GroupFeatures(features); var writeTasks = (from items in featureGroups select Task.Factory.StartNew(() => WriteFeaturesIntoQueue(items, featureSourceForRead))).ToArray(); var readTask = Task.Factory.StartNew(() => { while (!readCompleted || queue.Count > 0) { while (queue.Count > 0) { Collection<Feature> lineFeatures = queue.Dequeue(); SaveFeatures(lineFeatures, featureSourceForSave); } } }); Task.WaitAll(writeTasks); readCompleted = true; Task.WaitAny(readTask); #region Old version //foreach (Feature feature in features) //{ // Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature); // // Get the lineshape of the processing feature. // foreach (LineShape processingLineShape in processingLineShapes) // { // // Define a variable to save the points where the adjacent lines intersect with current processing line. // Collection<PointShape> crossingPoints = new Collection<PointShape>(); // // Get all the lines in current processing shape bounds. // Collection<Feature> adjacentFeatures = featureSourceForRead.GetFeaturesInsideBoundingBox(processingLineShape.GetBoundingBox(), ReturningColumnsType.NoColumns); // // Loop and see if the queried shape is intersected with processing shape. // foreach (Feature adjacentFeature in adjacentFeatures) // { // LineBaseShape adjacentLineShape = adjacentFeature.GetShape() as LineBaseShape; // MultipointShape tempCrossingPoints = processingLineShape.GetCrossing(adjacentLineShape); // // The queried shape is intersected with processing shape. // foreach (PointShape point in tempCrossingPoints.Points) // { // bool hasAdded = false; // foreach (var item in crossingPoints) // { // if (point.X == item.X && point.Y == item.Y) // { // hasAdded = true; // break; // } // } // if (!hasAdded) // { // crossingPoints.Add(point); // } // } // } // // Order the crossing points following the sequence of line vertex. // Collection<FlagedVertex> vertecesOfNewLine = GeometryHelper.AddCrossingPointToLine(processingLineShape, crossingPoints); // // Split current processing lineshape into segments. // featureSourceForSave.BeginTransaction(); // Collection<Vertex> verteces = new Collection<Vertex>(); // foreach (var vertex in vertecesOfNewLine) // { // verteces.Add(vertex.Vertex); // if (vertex.Flag) // { // if (verteces.Count >= 2) // { // LineShape segment = new LineShape(verteces); // featureSourceForSave.AddFeature(new Feature(segment, feature.ColumnValues)); // verteces.RemoveAt(0); // } // } // } // featureSourceForSave.CommitTransaction(); // } //#if DEBUG //Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, featureCount)); //#endif //} #endregion featureSourceForRead.Close(); featureSourceForSave.Close(); }
protected override int GetRouteSegmentCountCore() { return(featureSource.GetCount()); }