Пример #1
0
        ///
        ///   <summary> * Reads GPS tracks from a GPX file and writes tracks and their coordinates to
        ///   * the database.
        ///   *  </summary>
        ///   * <param name="is"> a input steam with gpx-xml data </param>
        ///   * <returns> long[] array of track ids written in the database </returns>
        ///   * <exception cref="SAXException"> a parsing error </exception>
        ///   * <exception cref="ParserConfigurationException"> internal error </exception>
        ///   * <exception cref="IOException"> a file reading problem </exception>
        ///
        public static GMap.NET.gpxType[] importGPXFile(string content)
        {
            //SAXParserFactory factory = SAXParserFactory.newInstance();
            GpxImporter handler = new GpxImporter();

            //SAXParser parser = factory.newSAXParser();
            Track[] trackIds = null;

            try
            {
                //long start = Java.Lang.JavaSystem.CurrentTimeMillis();

                handler.ParseURL(content);
                //parser.parse(@is, handler);

                //long end = Java.Lang.JavaSystem.CurrentTimeMillis();
                //Log.Debug(Constants.TAG, "Total import time: " + (end - start) + "ms");

                trackIds = handler.ImportedTrackIds;
            }
            finally
            {
                // delete track if not finished
                handler.rollbackUnfinishedTracks();
            }

            return(trackIds);
        }
Пример #2
0
        private void LoadGpx(string gpxData)
        {
            gpxType[] rs = GpxImporter.importGPXFile(gpxData);
            if (rs != null && rs.Length > 0)
            {
                gpxType r = rs[0];
                if (r != null)
                {
                    if (r.trk != null && r.trk.Length > 0)
                    {
                        foreach (var trk in r.trk)
                        {
                            List <PointLatLng> points = new List <PointLatLng>();

                            foreach (var seg in trk.trkseg)
                            {
                                foreach (var p in seg.trkpt)
                                {
                                    if (p.lat != 0.0m && p.lon != 0.0m)
                                    {
                                        points.Add(new PointLatLng((double)p.lat, (double)p.lon));
                                    }
                                }
                            }

                            DarwTrack(points);
                        }
                    }

                    if (r.wpt != null && r.wpt.Length > 0)
                    {
                        List <PointLatLng> points = new List <PointLatLng>();
                        foreach (var p in r.wpt)
                        {
                            if (p.lat != 0.0m && p.lon != 0.0m)
                            {
                                points.Add(new PointLatLng((double)p.lat, (double)p.lon));
                            }
                        }
                        DarwTrack(points);
                    }
                }
            }

            m_MainMap.ZoomAndCenterRoutes(null);
        }
Пример #3
0
        ///  
        ///   <summary> * Reads GPS tracks from a GPX file and writes tracks and their coordinates to
        ///   * the database.
        ///   *  </summary>
        ///   * <param name="is"> a input steam with gpx-xml data </param>
        ///   * <returns> long[] array of track ids written in the database </returns>
        ///   * <exception cref="SAXException"> a parsing error </exception>
        ///   * <exception cref="ParserConfigurationException"> internal error </exception>
        ///   * <exception cref="IOException"> a file reading problem </exception>
        ///   
        public static GMap.NET.gpxType[] importGPXFile(string content)
        {
            //SAXParserFactory factory = SAXParserFactory.newInstance();
            GpxImporter handler = new GpxImporter();
            //SAXParser parser = factory.newSAXParser();
            Track[] trackIds = null;

            try
            {
                //long start = Java.Lang.JavaSystem.CurrentTimeMillis();

                handler.ParseURL(content);
                //parser.parse(@is, handler);

                //long end = Java.Lang.JavaSystem.CurrentTimeMillis();
                //Log.Debug(Constants.TAG, "Total import time: " + (end - start) + "ms");

                trackIds = handler.ImportedTrackIds;
            }
            finally
            {
                // delete track if not finished
                handler.rollbackUnfinishedTracks();
            }

            return trackIds;
        }