-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelper.cs
59 lines (55 loc) · 2.2 KB
/
Helper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//-----------------------------------------------------------------------
// <copyright file="Helper.cs" company="Studio A&T s.r.l.">
// Copyright (c) Studio A&T s.r.l. All rights reserved.
// </copyright>
// <author>Nicogis</author>
//-----------------------------------------------------------------------
namespace Studioat.ArcGIS.Voronoi
{
using System;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
/// <summary>
/// class of helper
/// </summary>
internal static class Helper
{
/// <summary>
/// open file GDB
/// </summary>
/// <param name="path">path of file geodatabase</param>
/// <returns>objects workspace</returns>
internal static IWorkspace FileGdbWorkspaceFromPath(string path)
{
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
return workspaceFactory.OpenFromFile(path, 0);
}
/// <summary>
/// check exists file geodatabase
/// </summary>
/// <param name="pathFileName">path and name of geodatabase</param>
/// <returns>true if exists</returns>
internal static bool ExistsFileGdb(string pathFileName)
{
IWorkspaceFactory2 wsf = new FileGDBWorkspaceFactoryClass() as IWorkspaceFactory2;
return wsf.IsWorkspace(pathFileName);
}
/// <summary>
/// get spatial reference of feature class
/// </summary>
/// <param name="featureClass">object feature class</param>
/// <returns>object spatial reference</returns>
internal static ISpatialReference GetSpatialReference(IFeatureClass featureClass)
{
ISpatialReference spatialReference = null;
if (featureClass != null)
{
IGeoDataset geoDataset = featureClass as IGeoDataset;
spatialReference = geoDataset.SpatialReference;
}
return spatialReference;
}
}
}