forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeometryServicesExtensions.cs
More file actions
39 lines (30 loc) · 1.11 KB
/
GeometryServicesExtensions.cs
File metadata and controls
39 lines (30 loc) · 1.11 KB
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
using System.Globalization;
using System.Threading;
using GeoAPI.Geometries;
using GeoAPI.Utilities;
namespace GeoAPI
{
public static class GeometryServicesExtensions
{
private static readonly ThreadSafeStore<string, IGeometryFactory> _store;
static GeometryServicesExtensions()
{
_store = new ThreadSafeStore<string, IGeometryFactory>( t => GeometryServiceProvider.Instance.CreateGeometryFactory(GetSrid(t)));
}
private static int _userSrid = 100000000;
private static int GetSrid(string oid)
{
if (string.IsNullOrEmpty(oid))
return GeometryServiceProvider.Instance.DefaultSRID;
int srid;
if (int.TryParse(oid, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out srid))
return srid;
Interlocked.Increment(ref _userSrid);
return _userSrid;
}
public static IGeometryFactory CreateGeometryFactory(this IGeometryServices self, string oid)
{
return _store.Get(oid);
}
}
}