Example #1
0
 public static int MapTrackGPX(GPXFile gpxfile, out List <int> handles)
 {
     handles = new List <int>();
     if (gpxfile.Tracks.Count > 0)
     {
         var sf = ShapefileFactory.TrackFromGPX(gpxfile, out handles);
         MapLayersHandler.AddLayer(sf, "GPX track", uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);
     }
     return(MapLayersHandler.CurrentMapLayer.Handle);
 }
Example #2
0
        public static int MapGPX(GPXFile gpxFile, out int shpIndex, out List <int> handles, bool showInMap = true)
        {
            shpIndex = -1;
            handles  = new List <int>();
            var utils       = new MapWinGIS.Utils();
            var shpfileName = "";

            if (showInMap)
            {
                if (gpxFile != null)
                {
                    Shapefile sf = null;
                    if (gpxFile.TrackCount > 0)
                    {
                        //sf = ShapefileFactory.TrackFromGPX(gpxFile,out shpIndex);
                        sf          = ShapefileFactory.TrackFromGPX(gpxFile, out handles);
                        shpfileName = "GPX tracks";
                    }
                    else if (gpxFile.WaypointCount > 0)
                    {
                        sf          = ShapefileFactory.NamedPointsFromGPX(gpxFile, out handles);
                        shpfileName = "GPX waypoints";
                    }
                    //MapWindowForm.Title =$"Number of layers:{MapControl.NumLayers}";
                    MapLayersHandler.AddLayer(sf, shpfileName, uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);

                    if (gpxFile.TrackCount > 0)
                    {
                        GPXTracksLayer = MapLayersHandler.CurrentMapLayer;
                    }
                    else if (gpxFile.WaypointCount > 0)
                    {
                        GPXWaypointsLayer = MapLayersHandler.CurrentMapLayer;
                    }

                    return(MapLayersHandler.CurrentMapLayer.Handle);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                var ly = MapLayersHandler.get_MapLayer(gpxFile.FileName);
                MapLayersHandler.RemoveLayer(ly.Handle);
                return(-1);
            }
        }