Hello,
Is there any possibility to get the connection to my geodatabase using the .sde file connection generated with arcCatalog ? i looked at the tutorial but there's only how to open a local geodatabase .can any one help me
thanks advanced
Manel,
Here is a property of a class "WorkspaceInfo.ConnectionString" that accepts path to your ".sde" file to connect to a geodatabase. Hope it helps.
Hello,
Thanks for your answer , but WorkspaceInfo and ConnectionString works on version 10.2.7 and me am trying to work on arcGIS runtime version 100 didn't find wich library can replace WorkspaceInfo ? can any one help me please , thanks adavanced
This is a feature that is coming in Update 1 for LocalMapService. You should be able to create EnterpriseGeodatabaseWorkspace from either connection string or ArcSDE connection file and create a TableSublayerSource with this workspace for ArcGISMapImageSublayer. Dynamic rendering for ArcGISMapImageLayer is also new in Update 1.
Hello @Jennifer Nery
thanks for your answer ,
Is there any tutorial that shows how to use localMapService and EntrepriseGeodatabaseWorkspace from .sde file ? i'am a biginner on .net and arcGis runtime ?
Thanks for your help
I actually need to add a 3D cone on a feature class and i need to display a layers from feature classes as a map so i generated .mpk files to get access to the geodatabase using the local servers but still didn't make it here's my code
private Esri.ArcGISRuntime.Geometry.Geometry createCone3D()
{
var location = new MapPoint(-4.04, 70, 1000, SpatialReferences.Wgs84);
var coneSymbole = new SimpleMarkerSceneSymbol
{
Style = SimpleMarkerSceneSymbolStyle.Cone,
Color = Colors.Yellow,
Height = 3000,
Width = 1000,
Depth = 3000,AnchorPosition = SceneSymbolAnchorPosition.Bottom
};
var coneGraphic = new Graphic(location, coneSymbole);
var geom = coneGraphic.Geometry;
MySceneView.GraphicsOverlays[1].Graphics.Add(coneGraphic);
return geom;
}
private Esri.ArcGISRuntime.LocalServices.LocalServer _localServer;
private async void StartLocalServer()
{
//get the singleton LocalServer object using the static instance property
_localServer = Esri.ArcGISRuntime.LocalServices.LocalServer.Instance;//Handle the statusChanged event to react when the server is started
_localServer.StatusChanged += ServerStatusChanged;
//Start the local server instance
await _localServer.StartAsync();}
private async void ServerStatusChanged(object sender , Esri.ArcGISRuntime.LocalServices.StatusChangedEventArgs e)
{
//Check if the server started successfully
if(e.Status == Esri.ArcGISRuntime.LocalServices.LocalServerStatus.Started)
{
//Create a local feature service from a map package on diskLocalFeatureService featureService = new LocalFeatureService(@"C:\Users\mkeddar\Documents\ArcGIS\niveauDepartemental.mpk");
//Handle the status changed event to check when it's loaded
featureService.StatusChanged += async (svc, args) =>
{
//If started successfully , add a layer from the service
if (args.Status == LocalServerStatus.Started)
{
//Get the service URL
var featureServiceUrl = (svc as LocalFeatureService).Url.AbsoluteUri;
//Create a new service feature table
ServiceFeatureTable localServiceTable = new ServiceFeatureTable(new Uri(featureServiceUrl + "/2"));
//Create a new feature layer to display the features in the table
FeatureLayer featureLyr = new FeatureLayer(localServiceTable);var attribute = new Dictionary<String, object>();
attribute.Add("description", "description");var geomCone = createCone3D();
//create a new feature
var newFeature = localServiceTable.CreateFeature(attribute,geomCone); // here i don't know what to guive as parameters so i create a feature
//from my geometry geomCone
//add the new feature
await localServiceTable.AddFeatureAsync(newFeature);
//push this update (apply edits) to the feature serviceIReadOnlyList<EditResult> editResults = await localServiceTable.ApplyEditsAsync();
//check the results for errorsforeach(var r in editResults)
{
if (r.CompletedWithErrors)
{
Console.WriteLine("Edit ti Object" + "'failed'" + r.Error.Message);
}
}
}
};//Start the local feature service
await featureService.StartAsync();
But this didn't work ! iu have an invalidOperationException
can you help me please ;thanks a lot
I've tried to use (using Esri.ArcGISRuntime.LocalServices.EnterpriseGeodatabaseWorkspace;) but didn't recognize i admit that this is not working yet ? right
I think I understand your follow-up question now. If you're trying to replace your FeatureLayer renderer/symbology with scene symbol, this will not work. You can only use 3d symbol in GraphicsOverlay RenderingMode=DynamicMode (which is default mode).
So to add a cone symbol interactively in a SceneView, you can do:
public MainWindow()
{
InitializeComponent();
MyMapView.Scene = new Scene(Basemap.CreateTopographic());
MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()
{
Renderer = new SimpleRenderer()
{
Symbol = SimpleMarkerSceneSymbol.CreateCone(Colors.Red, 10000,10000)
}
});
}
private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
{
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
overlay.Graphics.Add(new Graphic(e.Location));
}
To add your FeatureLayer from an MPK, you can do:
try
{
var service = new LocalFeatureService(@"c:\data\PointsofInterest.mpk");
await service.StartAsync();
MyMapView.Scene.OperationalLayers.Add(new FeatureLayer(new Uri($"{service.Url}/0")));
MyMapView.Scene.OperationalLayers.Add(new FeatureLayer(new Uri($"{service.Url}/1")));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
To add a feature, you can do:
var layer = (FeatureLayer)MyMapView.Scene.OperationalLayers.FirstOrDefault(o => o is FeatureLayer); var table = ((ArcGISFeatureTable)layer.FeatureTable); var template = table.FeatureTemplates.FirstOrDefault() ?? table.FeatureTypes.FirstOrDefault(t => t.Templates.Any())?.Templates?.FirstOrDefault(); var feature = table.CreateFeature(template, e.Location); await table.AddFeatureAsync(feature);
To replace the layer's symbology, you can do:
var layer = (FeatureLayer)MyMapView.Scene.OperationalLayers.FirstOrDefault(o => o is FeatureLayer);
layer.Renderer = new SimpleRenderer()
{
Symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 10),
};
Note, however that 3D symbols is not supported in FeatureLayer (this is by current design).
Hi Manel,
To reply to your original question, you can follow these steps for installing Local Server and updating your WPF application NuGet reference. Be sure to choose v100.1.0. Either set install path (i.e. LocalServerEnvironment.InstallPath = @"C:\Program Files (x86)\ArcGIS SDKs") or enable SDE and other child packages in your AGSDeployment file.
You can use the following code to create EnterpriseGeodatabaseWorkspace. Be sure to replace with correct connection string or full ArcSDE file path.
var service = new LocalMapService(@"c:\Data\Sample.mpk");
service.SetDynamicWorkspaces(new DynamicWorkspace[]
{
EnterpriseGeodatabaseWorkspace.CreateFromConnectionString($"{Guid.NewGuid()}", "PASSWORD=password;SERVER=servername;INSTANCE=instancename;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=servername;DATABASE=databasename;USER=username;VERSION=dbo.DEFAULT;AUTHENTICATION_MODE=DBMS"),
EnterpriseGeodatabaseWorkspace.CreateFromConnectionFile($"{Guid.NewGuid()}", @"C:\Data\SampleConnection.sde")
});
await service.StartAsync();
MyMapView.Map.OperationalLayers.Add(new ArcGISMapImageLayer(service.Url));
You can retrieve workspace again using the following code.
var workspace = service.GetDynamicWorkspaces().FirstOrDefault(w => w is EnterpriseGeodatabaseWorkspace) as EnterpriseGeodatabaseWorkspace;
You can then create sublayer using this workspace. Be sure to replace with correct workspace name and apply the correct symbology (i.e. point features with marker symbols, line features with line symbols, polygon features with fill symbols, etc.).
layer.Sublayers.Clear();
layer.Sublayers.Add(new ArcGISMapImageSublayer(0, new TableSublayerSource(workspace.Id, "YourWorkspaceName"))
{
Renderer = new SimpleRenderer(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Colors.Blue, null))
});
This should work, can you give this a try?
As for your follow-up question, I am unclear about what you're trying to do with 3D symbol. Maybe try that you're able to load layers from mpk first. InvalidOperationException may be raised when edit is not enabled or table is not ready. To troubleshoot features not rendering, you can subscribe to LayerViewStateChanged of MapView/SceneView and check for layer view status (i.e. is it Active, OutOfScale, Error, NotVisible? Does layer.LoadError have a value?
Hello, thanks for your answer ,
I am a trainee in a company, and I was asked to look at the new technologies offered by arcGis runtime version 100.0, basically they want to migrate the architecture of a tool based on arcObject to ArcGis runtime version 100.1, There are 3D computations . Each equipment has a 3D servitude zone in conical or cylindrical or rectangular form and these geometries are registered in a feature classes in an enterprise geodatabase and can be retrieved .That I am looking for if it is possible to save 3D geometries in arcGis run time version 100.1