Esempio n. 1
0
        public static LineStringType ToGmlLineString(this LineString lineString)
        {
            LineStringType gmlLineString = new LineStringType();

            gmlLineString.Items1ElementName    = new Items1ChoiceType1[1];
            gmlLineString.Items1ElementName[0] = Items1ChoiceType1.posList;
            gmlLineString.Items1    = new object[1];
            gmlLineString.Items1[0] = ToGmlPosList(lineString.Coordinates.ToArray());
            return(gmlLineString);
        }
Esempio n. 2
0
        public static LineStringType ToGmlLineString(this LineString lineString)
        {
            LineStringType gmlLineString = new LineStringType();

            gmlLineString.ItemsElementName    = new ItemsChoiceType[1];
            gmlLineString.ItemsElementName[0] = ItemsChoiceType.posList;
            gmlLineString.Items    = new object[1];
            gmlLineString.Items[0] = ToGmlPosList(lineString.Positions.ToArray());
            return(gmlLineString);
        }
        // route service
        public List <ServiceGeo> doTestRouteService(double VDStart, double KDStart, double VDEnd, double KDEnd)
        {
            List <ServiceGeo> lstInfo         = new List <ServiceGeo>();
            XLSType           xLSTypeRequest  = createRouteServiceRequest(VDStart, KDStart, VDEnd, KDEnd);
            XLSType           xLSTypeResponse = RequestUtil.perform(xLSTypeRequest);

            if (xLSTypeResponse.Response.Exists)
            {
                ResponseType responseType = xLSTypeResponse.Response.First;
                DetermineRouteResponseType determineRouteResponseType = responseType.DetermineRouteResponse.First;
                if (determineRouteResponseType.RouteInstructionsList.Exists)
                {
                    RouteInstructionsListType routeInstructionsListType = determineRouteResponseType.RouteInstructionsList.First;

                    foreach (RouteInstructionType routeInstructionType in routeInstructionsListType.RouteInstruction)
                    {
                        ServiceGeo   Geo            = new ServiceGeo();
                        string       strInstruction = routeInstructionType.Instruction.First.Value;
                        string       strDescription = routeInstructionType.description.Value;
                        DistanceType distanceType   = routeInstructionType.distance.First;
                        string       strUnit        = distanceType.uom.Value;
                        string       strDistance    = distanceType.value2.Value.ToString();

                        RouteGeometryType  routeGeometryType = routeInstructionType.RouteInstructionGeometry.First;
                        LineStringType     lineStringType    = routeGeometryType.LineString.First;
                        string             strX = "";
                        string             strY = "";
                        DirectPositionType directPositionType = lineStringType.pos.First;
                        string[]           xy = directPositionType.Value.Split(new string[] { " " }, StringSplitOptions.None);
                        strX = xy[1];
                        strY = xy[0];
                        // ListViewItem listViewItem = new ListViewItem(new string[] { strInstruction, strDescription, strDistance, strUnit, strX, strY });
                        // this.listViewRouteInstructionsList.Items.Add(listViewItem);
                        Geo.DonVi      = strUnit.ToLower();
                        Geo.ChiDan     = strInstruction;
                        Geo.MoTa       = strDescription;
                        Geo.KhoangCach = (float)Math.Round(double.Parse(strDistance), 1);
                        Geo.KinhDo     = strX;
                        Geo.ViDo       = strY;
                        lstInfo.Add(Geo);
                    }
                    return(lstInfo);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
 private static Feature ConvertLineString(LineStringType lineString)
 {
     return(new Feature((Geometry) new OsmSharp.Geo.Geometries.LineString((IEnumerable <GeoCoordinate>)KmlFeatureStreamSource.ConvertCoordinates(lineString.coordinates)))
     {
         Attributes =
         {
             {
                 "id",
                 (object)lineString.id
             }
         }
     });
 }
Esempio n. 5
0
        public static LineString ToGeometry(this LineStringType lineString)
        {
            if (lineString.Items == null)
            {
                return(null);
            }

            List <IPosition> points = FromGMLData(lineString.Items, Array.ConvertAll <ItemsChoiceType, string>(lineString.ItemsElementName, i => i.ToString()));

            if (points.Count < 2)
            {
                throw new InvalidFormatException("invalid GML representation: LineString type must have at least 2 positions");
            }

            return(new LineString(points));
        }
Esempio n. 6
0
        static public AbstractGeometryType ToKml(IGeometry geometry)
        {
            if (geometry is IPoint)
            {
                PointType point = new PointType();
                point.coordinates = ((IPoint)geometry).X.ToString(_nhi) + "," + ((IPoint)geometry).Y.ToString(_nhi);
                return(point);
            }
            else if (geometry is IMultiPoint)
            {
            }
            else if (geometry is IPolyline)
            {
                IPolyline pLine = (IPolyline)geometry;
                if (pLine.PathCount == 1)
                {
                    LineStringType line = new LineStringType();
                    line.coordinates = ToKmlCoordinates(pLine[0]);
                    return(line);
                }
                else if (pLine.PathCount > 1)
                {
                    MultiGeometryType mGeom = new MultiGeometryType();
                    mGeom.Items = new AbstractGeometryType[pLine.PathCount];
                    for (int i = 0, to = pLine.PathCount; i < to; i++)
                    {
                        LineStringType line = new LineStringType();
                        line.coordinates = ToKmlCoordinates(pLine[i]);
                        mGeom.Items[i]   = line;
                    }
                }
            }
            else if (geometry is IPolygon)
            {
                //IPolygon poly = (IPolygon)geometry;
                //PolygonType polygon = new PolygonType();

                //polygon.o
            }
            return(null);
        }
Esempio n. 7
0
 public static LineStringType ToGmlLineString(this LineString lineString)
 {
     LineStringType gmlLineString = new LineStringType();
     gmlLineString.Items1ElementName = new Items1ChoiceType1[1];
     gmlLineString.Items1ElementName[0] = Items1ChoiceType1.posList;
     gmlLineString.Items1 = new object[1];
     gmlLineString.Items1[0] = ToGmlPosList(lineString.Positions.ToArray());
     return gmlLineString;
 }
Esempio n. 8
0
        private void AddPlaceMark(string p_strPlaceMarkName, string p_strPlaceMarkDesc, string p_strCoordinates, bool p_blnLine)
        {
            /*
             * <Placemark>
             * <name>Location 3</name>
             * <description>This is location 3</description>
             * <Point>
             * <coordinates>-122.063,37.4063228</coordinates>
             * </Point>
             * </Placemark>
             *
             * <Placemark>
             * <name>Yahoo! Inc.</name>
             * <description><![CDATA[
             * Yahoo! Inc.<br />
             * 701 First Avenue<br />
             * Sunnyvale, CA 94089<br />
             * Tel: (408) 349-3300<br />
             * Fax: (408) 349-3301<br />
             * <p>Home page: <a href="http://yahoo.com">http://yahoo.com</a></p>
             * ]]>
             * </description>
             * <Point>
             * <coordinates>-122.0250403,37.4163228</coordinates>
             * </Point>
             * </Placemark>
             *
             * <Placemark>
             * <name />
             * <description>[15-Aug-10 16:26:39] [264.26 km] [36.5 mph] [END]</description>
             * <styleUrl>#PointStyle</styleUrl>
             * <Point>
             * <coordinates>-2.15337666666667,55.5678933333333</coordinates>
             * </Point>
             * </Placemark>
             *
             * <Placemark>
             * <name>GPSTEST01 15-Aug-10 09:48:20</name>
             * <description />
             * <LineString>
             * <coordinates>-1.63345833333333,55.0660283333333 -1.63354,55.06615 -1.633455,55.0660683333333 -1.633465,55.0661516666667 -1.63344833333333,55.0662333333333 -1.63348333333333,55.066285 -1.63337,55.0662833333333 -1.633315,55.0663133333333 -1.633295,55.066355 -1.63326833333333,55.06632 </coordinates>
             * </LineString>
             * </Placemark>
             *
             *
             */
            PlacemarkType pm = new PlacemarkType();

            pm.name        = p_strPlaceMarkName;
            pm.description = p_strPlaceMarkDesc;


            if (p_blnLine)
            {
                LineStringType line = new LineStringType();

                pm.Item1 = line;

                line.coordinates = p_strCoordinates;

//				pm.styleUrl ="#LineStyle";
            }
            else
            {
                PointType point = new PointType();

                pm.Item1 = point;

                point.coordinates = p_strCoordinates;

                pm.styleUrl = "#PointStyle";
            }


            m_lPlaceMarks.Add(pm);
        }