Skip to content

Commit

Permalink
kleine aanpassing en split titel plus bug fixes
Browse files Browse the repository at this point in the history
close #119
close #120
close #121
  • Loading branch information
Mannus committed Aug 24, 2019
1 parent 88e839b commit 5f3368e
Show file tree
Hide file tree
Showing 11 changed files with 164,075 additions and 761 deletions.
70,276 changes: 70,276 additions & 0 deletions BikeTouringGIS.Library.UnitTests/119.gpx

Large diffs are not rendered by default.

93,748 changes: 93,748 additions & 0 deletions BikeTouringGIS.Library.UnitTests/120.gpx

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions BikeTouringGIS.Library/Services/GeometryFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ public void CreateGeometries()
{
_gpxInformation.WayPoints.ForEach(wp => CreateWayPointGeometry(wp));
var tracksToConvert = _gpxInformation.Tracks.Where(t => t.IsConvertedToRoute);
var routes = new List<Route>();
var originalRoutes = _gpxInformation.Routes;
var newRoutes = new List<Route>();
tracksToConvert.ForEach(t =>
{
Route newRoute = t.ConvertTrack();
originalRoutes.Add(newRoute);
});
originalRoutes.ForEach(r =>
{
var newRoute = r;
CreateRouteGeometry(newRoute);
routes.Add(newRoute);
newRoutes.Add(newRoute);
});
_gpxInformation.Routes = routes;
_gpxInformation.Routes = newRoutes;
var tracks = _gpxInformation.Tracks.Where(t => !t.IsConvertedToRoute);
tracks.ForEach(t => CreateTrackGeometry(t));
_gpxInformation.Tracks = tracks.ToList();
Expand Down
740 changes: 0 additions & 740 deletions BikeTouringGIS.sln

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions BikeTouringGIS/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ private void LogUnhandledException(Exception exception, string @event)
{
#if DEBUG
#else
ILogger logger = Logger.GetLogger();
logger.LogException(exception);
_log.Error(exception);
this.Shutdown();
#endif
}
Expand Down
3 changes: 3 additions & 0 deletions BikeTouringGIS/BikeTouringGIS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
<HintPath>..\packages\squirrel.windows.1.7.8\lib\Net45\Squirrel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Syroot.KnownFolders, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Syroot.Windows.IO.KnownFolders.1.2.1\lib\net452\Syroot.KnownFolders.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand Down
32 changes: 26 additions & 6 deletions BikeTouringGIS/Controls/BikeTouringGISLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Layers;
using Esri.ArcGISRuntime.Symbology;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
Expand All @@ -19,8 +20,8 @@ public class BikeTouringGISLayer : GraphicsLayer
private IPath _routeOrTrack;
private BikeTouringGISLayer _splitLayer;
private Dictionary<GraphicType, object> _symbols;
private bool _isInEditMode, _isSplitted, _isSelected;
private string _splitPrefix, _title;
private bool _isInEditMode, _isSplitted, _isSelected, _isSplitPrefixStillEqualToOriginal;
private string _splitPrefix, _title, _originalTitle;
private RouteSplitter _routeSplitter;
private int _totalLength, _splitDistance;
private Envelope _extent;
Expand All @@ -44,8 +45,9 @@ public BikeTouringGISLayer(string fileName, IPath routeOrTrack) : this(fileName)
{
_routeOrTrack = routeOrTrack;
Title = string.IsNullOrEmpty(_routeOrTrack.Name) ? Path.GetFileNameWithoutExtension(fileName) : _routeOrTrack.Name;
var subStringLength = Title.Length > 15 ? 15 : Title.Length;
SplitPrefix = Title.Substring(0, subStringLength);
_originalTitle = Title;
_isSplitPrefixStillEqualToOriginal = true;
SetSplitPrefix();
Graphics.Add(_routeOrTrack.StartLocation);
Graphics.Add(_routeOrTrack.EndLocation);
Graphics.Add(_routeOrTrack.Geometry);
Expand All @@ -63,6 +65,23 @@ public BikeTouringGISLayer(string fileName, IPath routeOrTrack) : this(fileName)
IsInEditMode = false;
}

private void SetSplitPrefix()
{
if (_isSplitPrefixStillEqualToOriginal)
{
var subStringLength = Title.Length > 15 ? 15 : Title.Length;
var splitPrefix = Title.Substring(0, subStringLength);
if (SplitPrefix == null || SplitPrefix.Equals(_originalTitle) || splitPrefix.StartsWith(SplitPrefix))
{
SplitPrefix = splitPrefix;
}
else
{
_isSplitPrefixStillEqualToOriginal = false;
}
}
}

public bool IsSelected
{
get { return _isSelected; }
Expand Down Expand Up @@ -178,7 +197,7 @@ internal void Save(IEnumerable<wptType> waypoints, string fileName = null)
var gpxFile = new GPXFile();
var gpx = new gpxType();
var rte = new rteType();
rte.name = Title;
rte.name = Title.Trim();
rte.rtept = ToRoute().Points.ToArray();
gpx.rte = new List<rteType>() { rte }.ToArray();
gpx.wpt = waypoints.ToArray();
Expand Down Expand Up @@ -302,8 +321,9 @@ public string Title
{
if (value != _title)
{
_title = value.Trim();
_title = value;
IsInEditMode = true;
SetSplitPrefix();
OnPropertyChanged("Title");
}
}
Expand Down
4 changes: 2 additions & 2 deletions BikeTouringGIS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0")]
[assembly: InternalsVisibleTo("BikeTouringGISLibrary.UnitTests")]
10 changes: 5 additions & 5 deletions BikeTouringGIS/Services/LayerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ public LayerFactory(Envelope wayPointsExtent)
_wayPointsExtent = wayPointsExtent;
}

internal List<BikeTouringGISLayer> CreateRoutes(List<Route> routes)
internal List<BikeTouringGISLayer> CreateRoutes(string fileName, List<Route> routes)
{
var result = new List<BikeTouringGISLayer>();
var result = new List<BikeTouringGISLayer>();
foreach (Route route in routes)
{
var layer = new BikeTouringGISLayer(route.FileName, route);
var layer = new BikeTouringGISLayer(fileName, route);
layer.SetExtentToFitWithWaypoints(_wayPointsExtent);
result.Add(layer);
}
return result;
}

internal List<BikeTouringGISLayer> CreateTracks(List<Track> tracks)
internal List<BikeTouringGISLayer> CreateTracks(string fileName, List<Track> tracks)
{
var result = new List<BikeTouringGISLayer>();
foreach (Track track in tracks)
{
var layer = new BikeTouringGISLayer(track.FileName, track);
var layer = new BikeTouringGISLayer(fileName, track);
layer.SetExtentToFitWithWaypoints(_wayPointsExtent);
result.Add(layer);
}
Expand Down
7 changes: 4 additions & 3 deletions BikeTouringGIS/ViewModels/BikeTouringGISViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using GalaSoft.MvvmLight.Command;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using Syroot.Windows.IO;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -127,7 +128,7 @@ private async void OpenGPXFile(BikeTouringGISMapViewModel mapViewModel)
Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
openFileDialog.Filter = "GPX files (*.gpx)|*.gpx";
openFileDialog.Multiselect = true;
openFileDialog.InitialDirectory = DropBoxHelper.GetDropBoxFolder();
openFileDialog.InitialDirectory = KnownFolders.Downloads.Path;
if (openFileDialog.ShowDialog() == true)
{
foreach (var file in openFileDialog.FileNames)
Expand Down Expand Up @@ -177,9 +178,9 @@ internal async void OpenGpxFile(BikeTouringGISMapViewModel mapViewModel, string
var geometryFactory = new GeometryFactory(gpxFileInformation);
geometryFactory.CreateGeometries();
var layerFactory = new LayerFactory(gpxFileInformation.WayPointsExtent);
var routes = layerFactory.CreateRoutes(gpxFileInformation.Routes);
var routes = layerFactory.CreateRoutes(path, gpxFileInformation.Routes);
mapViewModel.AddRoutes(routes);
var tracks = layerFactory.CreateTracks(gpxFileInformation.Tracks);
var tracks = layerFactory.CreateTracks(path, gpxFileInformation.Tracks);
mapViewModel.AddTracks(tracks);
mapViewModel.AddPoIs(gpxFileInformation.WayPoints);
}
Expand Down
1 change: 1 addition & 0 deletions BikeTouringGIS/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<package id="SharpCompress" version="0.18.2" targetFramework="net462" />
<package id="Splat" version="2.0.0" targetFramework="net461" />
<package id="squirrel.windows" version="1.7.8" targetFramework="net462" />
<package id="Syroot.Windows.IO.KnownFolders" version="1.2.1" targetFramework="net472" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net462" requireReinstallation="true" />
<package id="VersionHelpers" version="10.0.0.0" targetFramework="net461" />
</packages>

0 comments on commit 5f3368e

Please sign in to comment.