public static bool LoadCoastline(string coastlineShapeFile_FileName, bool visible = true)
        {
            bool coastlineLoaded = false;

            for (int h = 0; h < MapControl.NumLayers - 1; h++)
            {
                var sf = MapControl.get_GetObject(h) as Shapefile;
                if (sf.Key == "coastline")
                {
                    coastlineLoaded = true;
                    Coastline       = sf;
                    break;
                }
            }


            if (!coastlineLoaded && coastlineShapeFile_FileName != null && coastlineShapeFile_FileName.Length > 0)
            {
                Shapefile sf = new Shapefile();
                if (sf.Open(coastlineShapeFile_FileName))
                {
                    sf.Key = "coastline";
                    var h = MapLayersHandler.AddLayer(sf, "Coastline", uniqueLayer: true, isVisible: visible, layerKey: "coastline", rejectIfExisting: true);
                    Coastline = sf;
                }
            }
            return(Coastline != null);
        }
 public static int MapWaypointList(List <WaypointLocalTime> wpts, out List <int> handles)
 {
     handles = new List <int>();
     if (wpts.Count > 0)
     {
         var sf = ShapefileFactory.PointsFromWaypointList(wpts, out handles);
         MapLayersHandler.AddLayer(sf, "GPX waypoints", uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);
     }
     return(MapLayersHandler.CurrentMapLayer.Handle);
 }
Example #3
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);
 }
        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.TracksFromGPXFiles(gpxFile, out handles);
                        //var result = ShapefileFactory.CreateTripAndHaulsFromGPX(gpxFile);
                        //sf = result.Shapefile;
                        //handles.Add(result.Handle);
                        //Console.WriteLine($"shapefile with {sf.Shape[0].numPoints} created. Handle is {result.Handle}");
                        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);
            }
        }
        public static int MapExtractedFishingTracksShapefile(Shapefile extractedTracks)
        {
            RemoveGPSDataFromMap();
            var h = MapLayersHandler.AddLayer(extractedTracks, "Extracted tracks", uniqueLayer: true, layerKey: extractedTracks.Key, rejectIfExisting: true);

            var sf = (Shapefile)MapLayersHandler[h].LayerObject;

            sf.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.Salmon);
            sf.SelectionAppearance               = tkSelectionAppearance.saDrawingOptions;
            sf.SelectionDrawingOptions.LineWidth = 4f;
            return(h);
        }
 public static FishingTripAndGearRetrievalTracks MapTrackGPX(GPXFile gpxfile)
 {
     if (gpxfile.Tracks.Count > 0)
     {
         var result = ShapefileFactory.CreateTripAndHaulsFromGPX(gpxfile);
         if (result != null)
         {
             MapLayersHandler.AddLayer(result.TripShapefile, "GPX track", uniqueLayer: true, layerKey: result.TripShapefile.Key, rejectIfExisting: true);
         }
         return(result);
     }
     return(null);
 }
 public static FishingTripAndGearRetrievalTracks MapTrackCTX(CTXFileSummaryView ctx)
 {
     if (ctx.TrackpointsCount != null && ctx.TrackpointsCount > 0)
     {
         var result = ShapefileFactory.CreateTripAndHaulsFromCTX(ctx);
         if (result != null)
         {
             MapLayersHandler.AddLayer(result.TripShapefile, "CTX track", uniqueLayer: true, layerKey: result.TripShapefile.Key, rejectIfExisting: true);
         }
         return(result);
     }
     return(null);
 }
 public static int MapExtractedFishingTrack(FishingTripAndGearRetrievalTracks th, out List <int> handles)
 {
     handles = new List <int>();
     if (th != null && th.GearRetrievalTracks.Count > 0 && ShapefileFactory.ExtractFishingTrackLine)
     {
         var sf = ShapefileFactory.FishingTrackLine(th);
         if (sf != null)
         {
             return(MapLayersHandler.AddLayer(sf, "Extracted fishng track", uniqueLayer: true, layerKey: sf.Key));
         }
     }
     return(-1);
 }
 public static int MapExtractedFishingTrack(out List <int> handles)
 {
     handles = new List <int>();
     if (ShapefileFactory.ExtractFishingTrackLine)
     {
         var sf = ShapefileFactory.FishingTrackLine();
         if (sf != null)
         {
             //return MapLayersHandler.AddLayer(sf, "Extracted fishng track", uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);
             return(MapLayersHandler.AddLayer(sf, "Extracted fishng track", uniqueLayer: true, layerKey: sf.Key));
         }
     }
     return(-1);
 }
        public static bool AddExtractedTracksLayer(bool readFromDatabase = false)
        {
            bool proceed = true;

            if (readFromDatabase)
            {
                proceed = Entities.ExtractedFishingTrackViewModel.LoadTrackDataFromDatabase();
            }
            if (proceed && Entities.ExtractedFishingTrackViewModel.Count() > 0)
            {
                var sf = ShapefileFactory.FishingTrackLines();
                ExtractedTracksShapefile             = sf;
                sf.SelectionAppearance               = tkSelectionAppearance.saDrawingOptions;
                sf.DefaultDrawingOptions.LineColor   = new Utils().ColorByName(tkMapColor.Salmon);
                sf.SelectionDrawingOptions.LineWidth = 4f;
                return(MapLayersHandler.AddLayer(sf, "Fishing tracks", layerKey: sf.Key, uniqueLayer: true) >= 0);
            }
            return(false);
        }
Example #11
0
        public static int MapTripWaypoints(List <TripWaypoint> waypoints, out int shpIndex, out List <int> handles, GPS gps, string filename, bool showInMap = true)
        {
            shpIndex = -1;
            handles  = new List <int>();
            var utils       = new MapWinGIS.Utils();
            var shpfileName = "";

            if (showInMap)
            {
                if (waypoints.Count > 0)
                {
                    Shapefile sf = null;
                    sf          = ShapefileFactory.PointsFromWayPointList(waypoints, out handles, gps.DeviceName, filename);
                    shpfileName = "Trip waypoints";
                    int h = MapLayersHandler.AddLayer(sf, shpfileName, uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);
                }
            }
            return(MapLayersHandler.CurrentMapLayer.Handle);
        }
        public static int MapTrip(Trip trip, 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 (trip.Track.Waypoints.Count > 0)
                {
                    Shapefile   sf    = null;
                    List <Trip> trips = new List <Trip>();
                    trips.Add(trip);
                    sf          = ShapefileFactory.TrackFromTrip(trips, out handles);
                    shpfileName = "Trip tracks";
                    MapLayersHandler.AddLayer(sf, shpfileName, uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true);
                }
            }
            return(MapLayersHandler.CurrentMapLayer.Handle);
        }
        public static int MapWaypointsCTX(CTXFileSummaryView ctx, out List <int> handles)
        {
            handles = new List <int>();
            Shapefile sf = null;

            if (ctx.WaypointsForSet != null && ctx.WaypointsForSet > 0 ||
                ctx.WaypointsForHaul != null && ctx.WaypointsForHaul > 0)
            {
                sf = ShapefileFactory.WaypointsFromCTX(ctx, out handles);
            }

            if (sf != null)
            {
                return(MapLayersHandler.AddLayer(sf, "CTX waypoints", uniqueLayer: true, layerKey: sf.Key, rejectIfExisting: true));
                //return MapLayersHandler.CurrentMapLayer.Handle;
            }
            else
            {
                return(-1);
            }
        }