Skip to content

Commit

Permalink
Merged master into 'list transformations' sample branch and resolved …
Browse files Browse the repository at this point in the history
…conflicts.
  • Loading branch information
ThadT committed Feb 13, 2018
2 parents b7ce6f6 + f8a35f0 commit b3e5c82
Show file tree
Hide file tree
Showing 241 changed files with 6,604 additions and 620 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
</ItemGroup>
<ItemGroup>
<!-- JSON Metadata -->
<EmbeddedResource Include="Samples\Analysis\ViewshedGeoElement\metadata.json" />
<EmbeddedResource Include="Samples\GraphicsOverlay\Animate3DGraphic\metadata.json" />
<EmbeddedResource Include="Samples\GeometryEngine\ProjectWithSpecificTransformation\metadata.json" />
<EmbeddedResource Include="Samples\Data\ListRelatedFeatures\metadata.json" />
Expand Down Expand Up @@ -275,6 +276,7 @@
</ItemGroup>
<ItemGroup>
<!-- Screenshots -->
<None Include="Samples\Analysis\ViewshedGeoElement\ViewshedGeoElement.jpg" />
<None Include="Samples\GraphicsOverlay\Animate3DGraphic\Animate3DGraphic.jpg" />
<None Include="Samples\GeometryEngine\ProjectWithSpecificTransformation\ProjectWithSpecificTransformation.jpg" />
<None Include="Samples\Data\ListRelatedFeatures\ListRelatedFeatures.jpg" />
Expand Down Expand Up @@ -323,6 +325,8 @@
<None Include="Samples\Layers\FeatureLayerRenderingModeMap\FeatureLayerRenderingModeMap.jpg" />
<None Include="Samples\Layers\FeatureLayerSelection\FeatureLayerSelection.jpg" />
<None Include="Samples\Layers\FeatureLayerUrl\FeatureLayerUrl.jpg" />
<EmbeddedResource Include="Samples\Layers\RasterRgbRenderer\metadata.json" />
<EmbeddedResource Include="Samples\Layers\RasterHillshade\metadata.json" />
<None Include="Samples\Layers\RasterLayerFile\RasterLayerFile.jpg" />
<None Include="Samples\Layers\RasterLayerImageServiceRaster\RasterLayerImageServiceRaster.jpg" />
<None Include="Samples\Layers\RasterLayerRasterFunction\RasterLayerRasterFunction.jpg" />
Expand Down Expand Up @@ -370,6 +374,7 @@
</ItemGroup>
<ItemGroup>
<!-- Sample Code -->
<Compile Include="Samples\Analysis\ViewshedGeoElement\ViewshedGeoElement.cs" />
<Compile Include="Samples\GraphicsOverlay\Animate3DGraphic\Animate3DGraphic.cs" />
<Compile Include="Samples\Layers\ChangeBlendRenderer\ChangeBlendRenderer.cs" />
<Compile Include="Samples\GeometryEngine\ProjectWithSpecificTransformation\ProjectWithSpecificTransformation.cs" />
Expand Down Expand Up @@ -420,6 +425,8 @@
<Compile Include="Samples\Layers\FeatureLayerRenderingModeMap\FeatureLayerRenderingModeMap.cs" />
<Compile Include="Samples\Layers\FeatureLayerSelection\FeatureLayerSelection.cs" />
<Compile Include="Samples\Layers\FeatureLayerUrl\FeatureLayerUrl.cs" />
<Compile Include="Samples\Layers\RasterRgbRenderer\RasterRgbRenderer.cs" />
<Compile Include="Samples\Layers\RasterHillshade\RasterHillshade.cs" />
<Compile Include="Samples\Layers\RasterLayerFile\RasterLayerFile.cs" />
<Compile Include="Samples\Layers\RasterLayerImageServiceRaster\RasterLayerImageServiceRaster.cs" />
<Compile Include="Samples\Layers\RasterLayerRasterFunction\RasterLayerRasterFunction.cs" />
Expand Down Expand Up @@ -464,8 +471,17 @@
<Compile Include="Samples\Tutorial\AuthorEditSaveMap\AuthorEditSaveMap.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Samples\GeometryEngine\ListTransformations\ListTransformations.jpg" />
<None Include="Samples\Layers\RasterHillshade\RasterHillshade.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Samples\Symbology\FeatureLayerExtrusion\FeatureLayerExtrusion.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Samples\Layers\RasterRgbRenderer\RasterRgbRenderer.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Samples\GeometryEngine\ListTransformations\ListTransformations.jpg" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private async void Initialize()

// Add the taxi to the scene
// Create the model symbol for the taxi
ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(await GetModelUri());
ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(await GetModelUri()));
// Set the anchor position for the mode; ensures that the model appears above the ground
taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom;
// Create the graphic from the taxi starting point and the symbol
Expand Down Expand Up @@ -217,7 +217,7 @@ private void UpdateUiAndSelection()
}
}

private async Task<Uri> GetModelUri()
private async Task<string> GetModelUri()
{
// Returns the taxi model

Expand All @@ -235,12 +235,12 @@ private async Task<Uri> GetModelUri()
// Check if the file exists
if (!File.Exists(filepath))
{
// If it's missing, download the GeoPackage
// If it's missing, download the model
await DataManager.GetData("3af5cfec0fd24dac8d88aea679027cb9", "LineOfSightGeoElement");
}

// Return the path
return new Uri(filepath);
return filepath;

#endregion offlinedata
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@
"DataFileNames": [ "dolmus.3ds" ],
"Image": "LineOfSightGeoElement.jpg",
"Link": "",
"TypeLink": [],
"TypeLink": [
"T:Esri.ArcGISRuntime.Symbology.SimpleMarkerSceneSymbol",
"T:Esri.ArcGISRuntime.UI.GeoAnalysis.GeoElementLineOfSight",
"M:Esri.ArcGISRuntime.Mapping.LayerSceneProperties.#ctor(Esri.ArcGISRuntime.Mapping.SurfacePlacement)",
"M:Esri.ArcGISRuntime.UI.GeoAnalysis.GeoElementLineOfSight.#ctor(Esri.ArcGISRuntime.Data.GeoElement,Esri.ArcGISRuntime.Data.GeoElement)",
"T:Esri.ArcGISRuntime.Symbology.SceneSymbolAnchorPosition",
"T:Esri.ArcGISRuntime.UI.GeoAnalysis.LineOfSightTargetVisibility",
"E:Esri.ArcGISRuntime.UI.GeoAnalysis.LineOfSight.TargetVisibilityChanged",
"P:Esri.ArcGISRuntime.Mapping.Scene.InitialViewpoint",
"P:Esri.ArcGISRuntime.Symbology.MarkerSceneSymbol.AnchorPosition",
"P:Esri.ArcGISRuntime.UI.GeoAnalysis.GeoElementLineOfSight.TargetOffsetZ",
"P:Esri.ArcGISRuntime.UI.GeoAnalysis.LineOfSight.TargetVisibility",
"P:Esri.ArcGISRuntime.UI.Graphic.IsSelected",
"M:Esri.ArcGISRuntime.Symbology.ModelSceneSymbol.CreateAsync(System.Uri)",
"T:Esri.ArcGISRuntime.Symbology.ModelSceneSymbol"
],
"SampleFolder": "LineOfSightGeoElement"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"Link": "",
"TypeLink": [
"M:Esri.ArcGISRuntime.Data.FeatureTable.QueryFeatureCountAsync(Esri.ArcGISRuntime.Data.QueryParameters)",
"M:Esri.ArcGISRuntime.Data.FeatureTable.QueryExtentAsync(Esri.ArcGISRuntime.Data.QueryParameters)"
"M:Esri.ArcGISRuntime.Data.FeatureTable.QueryExtentAsync(Esri.ArcGISRuntime.Data.QueryParameters)",
"P:Esri.ArcGISRuntime.Data.QueryParameters.SpatialRelationship"
],
"SampleFolder": "QueryFeatureCountAndExtent"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
// Copyright 2018 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Android.App;
using Android.OS;
using Android.Widget;
using ArcGISRuntimeXamarin.Managers;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using Esri.ArcGISRuntime.UI.GeoAnalysis;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Timers;

namespace ArcGISRuntimeXamarin.Samples.ViewshedGeoElement
{
[Activity]
public class ViewshedGeoElement : Activity
{
// Create and hold reference to the used SceneView.
private readonly SceneView _mySceneView = new SceneView();

// URLs to the scene layer with buildings and the elevation source
private readonly Uri _elevationUri = new Uri("https://scene.arcgis.com/arcgis/rest/services/BREST_DTM_1M/ImageServer");
private readonly Uri _buildingsUri = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0");

// Graphic and overlay for showing the tank
private readonly GraphicsOverlay _tankOverlay = new GraphicsOverlay();
private Graphic _tank;

// Animation properties
private MapPoint _tankEndPoint;

// Units for geodetic calculation (used in animating tank)
private readonly LinearUnit _metersUnit = (LinearUnit)Unit.FromUnitId(9001);
private readonly AngularUnit _degreesUnit = (AngularUnit)Unit.FromUnitId(9102);

protected override async void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

Title = "Viewshed (GeoElement)";

// Create the UI, setup the control references and execute initialization.
CreateLayout();
await Initialize();
}

private async Task Initialize()
{
// Create the scene with an imagery basemap.
_mySceneView.Scene = new Scene(Basemap.CreateImagery());

// Add the elevation surface.
ArcGISTiledElevationSource tiledElevationSource = new ArcGISTiledElevationSource(_elevationUri);
Surface baseSurface = new Surface
{
ElevationSources = { tiledElevationSource }
};
_mySceneView.Scene.BaseSurface = baseSurface;

// Add buildings.
_mySceneView.Scene.OperationalLayers.Add(new ArcGISSceneLayer(_buildingsUri));

// Configure the graphics overlay for the tank and add the overlay to the SceneView.
_tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
_mySceneView.GraphicsOverlays.Add(_tankOverlay);

// Configure the heading expression for the tank; this will allow the
// viewshed to update automatically based on the tank's position.
SimpleRenderer renderer3D = new SimpleRenderer();
renderer3D.SceneProperties.HeadingExpression = "[HEADING]";
_tankOverlay.Renderer = renderer3D;

// Create the tank graphic - get the model path.
string modelPath = await GetModelPath();
// - Create the symbol and make it 10x larger (to be the right size relative to the scene).
ModelSceneSymbol tankSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 10);
// - Adjust the position.
tankSymbol.Heading = 90;
// - The tank will be positioned relative to the scene surface by its bottom
// This ensures that the tank is on the ground rather than partially under it.
tankSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom;
// - Create the graphic.
_tank = new Graphic(new MapPoint(-4.506390, 48.385624, SpatialReferences.Wgs84), tankSymbol);
// - Update the heading.
_tank.Attributes["HEADING"] = 0.0;
// - Add the graphic to the overlay.
_tankOverlay.Graphics.Add(_tank);

// Create a viewshed for the tank.
GeoElementViewshed geoViewshed = new GeoElementViewshed(
geoElement: _tank,
horizontalAngle: 90.0,
verticalAngle: 40.0,
minDistance: 0.1,
maxDistance: 250.0,
headingOffset: 0.0,
pitchOffset: 0.0)
{
// Offset viewshed observer location to top of tank.
OffsetZ = 3.0
};

// Create the analysis overlay and add to the scene.
AnalysisOverlay overlay = new AnalysisOverlay();
overlay.Analyses.Add(geoViewshed);
_mySceneView.AnalysisOverlays.Add(overlay);

// Create a camera controller to orbit the tank.
OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(_tank, 200.0)
{
CameraPitchOffset = 45.0
};
// - Apply the camera controller to the SceneView.
_mySceneView.CameraController = cameraController;

// Create a timer; this will enable animating the tank.
Timer animationTimer = new Timer(60)
{
Enabled = true,
AutoReset = true
};
// - Move the tank every time the timer expires.
animationTimer.Elapsed += (o, e) =>
{
AnimateTank();
};
// - Start the timer.
animationTimer.Start();

// Allow the user to click to define a new destination.
_mySceneView.GeoViewTapped += (sender, args) => { _tankEndPoint = args.Location; };
}

private void AnimateTank()
{
// Return if tank already arrived.
if (_tankEndPoint == null)
{
return;
}

// Get current location and distance from the destination.
MapPoint location = (MapPoint)_tank.Geometry;
GeodeticDistanceResult distance = GeometryEngine.DistanceGeodetic(
location, _tankEndPoint, _metersUnit, _degreesUnit, GeodeticCurveType.Geodesic);

// Move the tank a short distance.
location = GeometryEngine.MoveGeodetic(new List<MapPoint>() { location }, 1.0, _metersUnit, distance.Azimuth1, _degreesUnit,
GeodeticCurveType.Geodesic).First();
_tank.Geometry = location;

// Rotate to face the destination.
double heading = (double)_tank.Attributes["HEADING"];
heading = heading + ((distance.Azimuth1 - heading) / 10);
_tank.Attributes["HEADING"] = heading;

// Clear the destination if the tank already arrived.
if (distance.Distance < 5)
{
_tankEndPoint = null;
}
}

private async Task<string> GetModelPath()
{
// Returns the tank model.

#region offlinedata

// The desired model is expected to be called "bradle.3ds".
string filename = "bradle.3ds";

// The data manager provides a method to get the folder.
string folder = DataManager.GetDataFolder();

// Get the full path.
string filepath = Path.Combine(folder, "SampleData", "ViewshedGeoElement", filename);

// Check if the file exists.
if (!File.Exists(filepath))
{
// If the model is missing, download it.
await DataManager.GetData("07d62a792ab6496d9b772a24efea45d0", "ViewshedGeoElement");
}

// Return the path.
return filepath;

#endregion offlinedata
}

private void CreateLayout()
{
// Create a new vertical layout for the app.
var layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

// Add the map view to the layout.
layout.AddView(_mySceneView);

// Show the layout in the app.
SetContentView(layout);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"Name": "Viewshed (GeoElement)",
"SampleName": "ViewshedGeoElement",
"Description": "This sample demonstrates how to display a live viewshed analysis for a moving GeoElement. The analysis is offset vertically so that the viewpoint is from the top of the GeoElement (in this case, a model of a tank).",
"Instructions": "Tap on the scene to see the tank move to that point.",
"Type": 0,
"RequiresOnlineConnection": true,
"RequiresOfflineData": true,
"RequiresLocalServer": false,
"DataItemIds": ["07d62a792ab6496d9b772a24efea45d0"],
"DataFileNames": ["bradle.3ds"],
"Image": "ViewshedGeoElement.jpg",
"Link": "",
"TypeLink": ["T:Esri.ArcGISRuntime.UI.GeoAnalysis.GeoElementViewshed",
"M:Esri.ArcGISRuntime.UI.GeoAnalysis.GeoElementViewshed.#ctor(Esri.ArcGISRuntime.Data.GeoElement,System.Double,System.Double,System.Double,System.Double,System.Double,System.Double)",
"M:Esri.ArcGISRuntime.Geometry.Unit.FromUnitId(System.Int32)",
"T:Esri.ArcGISRuntime.Geometry.LinearUnit",
"T:Esri.ArcGISRuntime.Geometry.AngularUnit",
"P:Esri.ArcGISRuntime.Symbology.RendererSceneProperties.HeadingExpression",
"T:Esri.ArcGISRuntime.Geometry.GeodeticDistanceResult",
"F:Esri.ArcGISRuntime.Geometry.GeodeticCurveType.Geodesic",
"M:Esri.ArcGISRuntime.Geometry.GeometryEngine.MoveGeodetic(System.Collections.Generic.IEnumerable{Esri.ArcGISRuntime.Geometry.MapPoint},System.Double,Esri.ArcGISRuntime.Geometry.LinearUnit,System.Double,Esri.ArcGISRuntime.Geometry.AngularUnit,Esri.ArcGISRuntime.Geometry.GeodeticCurveType)"
],
"SampleFolder": "ViewshedGeoElement"
}
Loading

0 comments on commit b3e5c82

Please sign in to comment.