# AdventureTraveler KML
Generate user-uploaded itineraries GPS and photos and videos are integrated into videos
## Development Platform
Visual Studio
net6.0
## Use plugin
AWSSDK S3 v3.7.9.63
Esri.ArcGISRuntime v100.15.0
Esri.ArcGISRuntime.Hydrography v100.15.0
Esri.ArcGISRuntime.WPF v100.15.0
FFME.Windows v4.4.350
FFMpegCore v4.8.0
MediaPlayer.WPF v1.0.1
MediaPlayer.WPF.Mpv v1.0.1
RestSharp v108.0.2
System.Data.SqlClient v4.8.3
## Logic

## Program Logic
### App.cs
>When the program starts running, it will first initialize the SQL data and obtain the journey creation data.
>GetCommandLineArgs analyzes the purpose of this operation
>*Due to the test period, the GPU will not be able to draw the content because the device goes to sleep, so it is necessary to simulate moving the mouse to wake up the device first.
>Get keywords from CommandLine "Tour" Obtain the content to be processed this time from the SQL data If there are no items to be processed, close the application If necessary, call StartBuild to let the application start generating video production
>Requires ArcGIS to apply for an ApiKey and fill it in before getting started
```
Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey = "APIKEY"
```
[APIKEY](https://developers.arcgis.com/dashboard/)

### MainWindow.cs

>Extra player for inserting videos or photos on the go
```
MediaElement mePlayer
mePlayer.MediaEnded += MePlayer_MediaEnded;
mePlayer.MediaOpened += (obj, e) =>
{
mePlayer.Play();
};
mePlayer.MediaFailed += MePlayer_MediaFailed;
//
mePlayer.LoadedBehavior = System.Windows.Controls.MediaState.Play;
mePlayer.UnloadedBehavior = System.Windows.Controls.MediaState.Manual;
mePlayer.Stretch = System.Windows.Media.Stretch.Uniform;
```
>MePlayer_MediaEnded
>> dgment at the end of the video Pre-play and playback of photos and videos are processed individually, whether there is a next video or photo
>>
>MePlayer_MediaFailed
>> Video failure judgment Add the failure content of the Error information, and then judge whether there is the next video or photo
```
// Create an elevation source to show relief in the scene.
string elevationServiceUrl = "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer";
ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(new Uri(elevationServiceUrl));
// Create a Surface with the elevation data.
Surface elevationSurface = new Surface();
elevationSurface.ElevationSources.Add(elevationSource);
// Add an exaggeration factor to increase the 3D effect of the elevation.
elevationSurface.ElevationExaggeration = 0.1f;
elevationSurface.NavigationConstraint = NavigationConstraint.StayAbove;
// Apply the surface to the scene.
scene.BaseSurface = elevationSurface;
```
>Initialize the map interface required by ArcGIS
```
System.Timers.Timer t = new System.Timers.Timer(60000);
t.Elapsed += new ElapsedEventHandler((o, e) =>
{
if (mReBuildCount > REBUILD_COUNT)
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
{
System.Diagnostics.Process.Start(App.EXE_PATH, "StartBuild");
Environment.Exit(0);
Application.Current.Shutdown();
}));
}
else
{
mReBuildCount = mReBuildCount + 1;
}
});
t.Start();
```
>Set confirmation time to avoid errors caused by prolonged inactivity
```
InitKML
```
>Get everything you need to get Data, including GPS user email, journey id, total miles, time, etc.
>Use the conversion method **GPXtoKML**
>And insert the GPS location of videos and photos into the KML data
```
GPXtoKML
```
>Convert the original GPS information into KML format through processing
```
LoadKmlTour
```