ThinkGeo.com    |     Documentation    |     Premium Support

Routing with Well Known Text

Hi,


How can I route with Well Known Text and show markers for each master points.


for example this route has 4 mater point.


MULTILINESTRING((29.094464 40.97111,29.094439 40.970553,29.094338 40.970172),(29.094338 40.970172,29.094179 40.969914,29.093935 40.969656,29.093557 40.96932,29.092858 40.968699,29.092752 40.968605,29.092465 40.968433),(29.090584 40.967698,29.09091 40.967776,29.091121 40.967847,29.092158 40.968353,29.092465 40.968433),(29.090007 40.967734,29.090584 40.967698),(29.0898 40.967764,29.090007 40.967734),(29.088944 40.967915,29.089321 40.967849,29.089569 40.967805,29.0898 40.967764),(29.088944 40.967915,29.088722 40.967224,29.088686 40.966967,29.089231 40.966724,29.089874 40.966346),(29.088944 40.967915,29.088722 40.967224,29.088686 40.966967,29.089231 40.966724,29.089874 40.966346),(29.089874 40.966346,29.089028 40.965457),(29.089028 40.965457,29.088981 40.965407,29.08814 40.96496),(29.08814 40.96496,29.087432 40.965763),(29.08733 40.965723,29.087432 40.965763),(29.086784 40.965448,29.08733 40.965723),(29.086439 40.964955,29.086784 40.965448),(29.086439 40.964955,29.085454 40.965276),(29.085454 40.965276,29.084637 40.965521),(29.084637 40.965521,29.083903 40.965759),(29.083903 40.965759,29.083057 40.966063),(29.083903 40.965759,29.083057 40.966063),(29.083057 40.966063,29.081979 40.966401),(29.081979 40.966401,29.081256 40.966733),(29.081256 40.966733,29.081017 40.966848,29.080809 40.967184),(29.080392 40.967383,29.080809 40.967184),(29.080392 40.967383,29.07988 40.966963),(29.07988 40.966963,29.079204 40.966474,29.079128 40.966432,29.078905 40.966305,29.078807 40.96625),(29.078807 40.96625,29.078678 40.966233,29.078571 40.96627),(29.078571 40.96627,29.07833 40.966449,29.078262 40.966493,29.077205 40.966907),(29.077205 40.966907,29.076489 40.967221),(29.077166 40.968082,29.076489 40.967221),(29.07753 40.968558,29.077166 40.968082),(29.07753 40.968558,29.07738 40.968862),(29.07738 40.968862,29.077022 40.969643,29.076728 40.969785,29.075917 40.970085))


with code example please.


Thanks



Ayhan,


 I have your route displayed in my sample as you can see in the screen shot using the code below. But I am not sure what you want exactely. What do you mean by 4 master points?


 You can also see that we have some sample on styles for displaying routes in the Code Community. You can check that out and provide us with more information on your case. Thank you.


Routing Styles wiki.thinkgeo.com/wiki/Map_Suite_Wp...ing_Styles




wpfMap1.MapUnit = GeographyUnit.DecimalDegree;

WorldMapKitWmsWpfOverlay worldMapKitWpfOverlay = new WorldMapKitWmsWpfOverlay();
wpfMap1.Overlays.Add(worldMapKitWpfOverlay);


string WKT = "Your WKT string ...";  

MultilineShape multilineShape = new MultilineShape(WKT);

InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();

Feature multiLineFeature = new Feature(multilineShape);

inMemoryFeatureLayer.InternalFeatures.Add(multiLineFeature);

inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Red, 3, true);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

LayerOverlay dynamicOverlay = new LayerOverlay();
dynamicOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryFeatureLayer);
wpfMap1.Overlays.Add("LayerOverlay", dynamicOverlay);


wpfMap1.CurrentExtent = new RectangleShape(28, 41, 27, 39);

wpfMap1.Refresh();


Thanks Val, 

4 master points means that route has 4 markers on it (start point, middle points... end point) and I want to show them with markers. 



thanks. 



 



Ayhan,


 I think I understand a little more what you are trying to do. I created a custom PointStyle (CustomStartEndStyle) where you can specify the type of start point style, end point style and mid point style. You can also specify the distance from the first point for your mid points so that they can be displayed at the correct location on the route line. Please see the code below and you will understand. Thank you.



 


 



wpfMap1.MapUnit = GeographyUnit.DecimalDegree;

WorldMapKitWmsWpfOverlay worldMapKitWpfOverlay = new WorldMapKitWmsWpfOverlay();
worldMapKitWpfOverlay.Projection = WorldMapKitProjection.DecimalDegrees;
wpfMap1.Overlays.Add(worldMapKitWpfOverlay);

string WKT = "Your WKT string ... ";   
                                                  
MultilineShape multilineShape = new MultilineShape(WKT);

InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();

Feature multiLineFeature = new Feature(multilineShape);
           
inMemoryFeatureLayer.InternalFeatures.Add(multiLineFeature);
          
CustomStartEndLineStyle customStartEndLineStyle = new CustomStartEndLineStyle(new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.StandardColors.Green), new GeoPen(GeoColor.StandardColors.Black),12),
    new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.StandardColors.Red), new GeoPen(GeoColor.StandardColors.Black), 12), new LineStyle(new GeoPen(GeoColor.StandardColors.DarkKhaki, 3)));

customStartEndLineStyle.MidPointStyle = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.StandardColors.BlueViolet), new GeoPen(GeoColor.StandardColors.Black), 8);
customStartEndLineStyle.GeographyUnit = wpfMap1.MapUnit;
customStartEndLineStyle.DistanceUnit = DistanceUnit.Meter;
customStartEndLineStyle.MidPoints.Add(1000); //1000 meters fromn the first point of the route line
customStartEndLineStyle.MidPoints.Add(1850);  //1850 meters fromn the first point of the route line
customStartEndLineStyle.MidPoints.Add(2250); //2250 meters fromn the first point of the route line

inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(customStartEndLineStyle);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

LayerOverlay dynamicOverlay = new LayerOverlay();
dynamicOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryFeatureLayer);
wpfMap1.Overlays.Add("LayerOverlay", dynamicOverlay);

wpfMap1.CurrentExtent = new RectangleShape(29.05, 40.99, 29.1, 40.95);

wpfMap1.Refresh();

  class CustomStartEndLineStyle : LineStyle
    {
        private PointStyle startPointStyle;
        private PointStyle endPointStyle;
        private LineStyle lineStyle;
        private PointStyle midPointStyle;
        private Collection<double> midPoints = new Collection<double>();
        private GeographyUnit geographyUnit;
        private DistanceUnit distanceUnit;

        public CustomStartEndLineStyle()
            : this(new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.StandardColors.Green), 12), 
               new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.StandardColors.Red), 12),
               new LineStyle(new GeoPen(GeoColor.FromArgb(150,GeoColor.StandardColors.BlueViolet),6)))
        { }

        public CustomStartEndLineStyle(PointStyle StartPointStyle, PointStyle EndPointStyle, LineStyle LineStyle)
        {
            this.startPointStyle = StartPointStyle;
            this.endPointStyle = EndPointStyle;
            this.lineStyle = LineStyle;
        }

        public PointStyle MidPointStyle
        {
            get { return midPointStyle; }
            set { midPointStyle = value; }
        }

        public Collection<double> MidPoints
        {
            get { return midPoints; }
            set { midPoints = value; }
        }

        //The unit the shape is in.
        public GeographyUnit GeographyUnit
        {
            get { return geographyUnit; }
            set { geographyUnit = value; }
        }

        //The unit of the mid points from the first vertex.
        public DistanceUnit DistanceUnit
        {
            get { return distanceUnit; }
            set { distanceUnit = value; }
        }
            

        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
        {
           //Loops thru the features 
            foreach (Feature feature in features)
            {
                Collection<BaseShape> startPointShapes = new Collection<BaseShape>();
                Collection<BaseShape> endPointShapes = new Collection<BaseShape>();
                Collection<BaseShape> multiLineShapes = new Collection<BaseShape>();
                Collection<BaseShape> midPointShapes = new Collection<BaseShape>();

                MultilineShape multilineShape = (MultilineShape)feature.GetShape();
                multiLineShapes.Add(multilineShape);

                foreach (double midPoint in midPoints)
                {
                    midPointShapes.Add(multilineShape.GetPointOnALine(StartingPoint.FirstPoint, midPoint, geographyUnit, distanceUnit));
                }
               
                startPointShapes.Add(new PointShape(multilineShape.Lines[0].Vertices[0]));
                
                LineShape lastLineShape = multilineShape.Lines[multilineShape.Lines.Count -1];
                endPointShapes.Add(new PointShape(lastLineShape.Vertices[lastLineShape.Vertices.Count -1]));

                lineStyle.Draw(multiLineShapes, canvas, labelsInThisLayer, labelsInAllLayers);
                startPointStyle.Draw(startPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
                midPointStyle.Draw(midPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
                endPointStyle.Draw(endPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
            }
        }
    }


Thanks Val...


Sorry about my question because I use MapSuite Web Edition not WPF. So I changed appropriate code like :


LayerOverlay dynamicOverlay = new LayerOverlay();

dynamicOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryFeatureLayer);


Map1.DynamicOverlay.Layers.Add("LayerOverlay", dynamicOverlay.Layers[0]);


Map1.DynamicOverlay.Redraw();




but it does not draw, and also if I understang it good you add custom points on the route  not the wellknowntext that contains user added points. If so I need user added points.


Thanks.



Sorry Val,


it draws but out side the turkey map (istanbul).



So I change the question


1- These are custom added points not the wellknowtext that contains user added points. So I need user added points.


2- if we can do this with wellknowtext  I need it editable so the user can chage the route again.


3- and changing wellknowntext projection so I can show the route where was it


thanks.



Ayhan,


 You are going to have to be more specific and explanative in your questions. I see you have three questions. Can you elaborate each one of them so that we can understand clearly what you need exactely? Also, give a general background of your map so that we have some context. That, also, always helps. Thank you.





Val, 



The wellknowntext that contains a route that I send you is made by an user. So the user wants it back to see as made it before which exactly with user added points (markers) and also wants to edit again (changing route). The our map unit is meter. we use EPSG:900913 projection.


Note : We use MapSuite Web Edition and MapSuite Routing



Thanks Val. 

 



Ayhan,


The requirements you are asking are still pretty vague and I believe that they are beyond the scope of regular support. You will be contacted by your account rep so that your case can be handled adequately. Thank you.