diff --git a/Clean.bat b/Clean.bat new file mode 100644 index 0000000..c53493f --- /dev/null +++ b/Clean.bat @@ -0,0 +1,9 @@ +@ECHO OFF + +FOR /R /D %%i in (obj\*) DO @RMDIR /S /Q %%i +FOR /R %%i in (obj\*) DO @DEL /Q %%i + +FOR /R /D %%i in (IVV.VENUS.*\bin\*) DO @RMDIR /S /Q %%i +FOR /R %%i in (IVV.VENUS.*\bin\*) DO @DEL /Q %%i + +@ECHO ON \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..e5d6f76 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,26 @@ + + + + Copyright 2014-$([System.DateTime]::UtcNow.Year) SharpMap - Team + 1701;1702;2100;2235 + true + https://github.com/SharpMap/SharpMap.BusinessObjects.git + git + https://github.com/SharpMap/SharpMap.BusinessObjects + SharpMap.Logo.png + + + + true + true + true + snupkg + + + + + + + + + diff --git a/src/GitVersion.yml b/src/GitVersion.yml new file mode 100644 index 0000000..3ab1e2e --- /dev/null +++ b/src/GitVersion.yml @@ -0,0 +1,4 @@ +next-version: 1.2.0 +branches: {} +ignore: + sha: [] diff --git a/src/SharpMap.BusinessObjects.EF6/Properties/AssemblyInfo.cs b/src/SharpMap.BusinessObjects.EF6/Properties/AssemblyInfo.cs deleted file mode 100644 index 48ae2e8..0000000 --- a/src/SharpMap.BusinessObjects.EF6/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("SharpMap.Business.EF6")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SharpMap.Business.EF6")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("656f9f14-4de1-4316-8bd1-11c8117fa7fa")] - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SharpMap.BusinessObjects.EF6/SharpMap.BusinessObjects.EF6.csproj b/src/SharpMap.BusinessObjects.EF6/SharpMap.BusinessObjects.EF6.csproj index 28e5ab1..dad5583 100644 --- a/src/SharpMap.BusinessObjects.EF6/SharpMap.BusinessObjects.EF6.csproj +++ b/src/SharpMap.BusinessObjects.EF6/SharpMap.BusinessObjects.EF6.csproj @@ -1,163 +1,29 @@ - - - + + - Debug - AnyCPU - {F2EF6114-B690-45A6-BDAD-4F362EF0BC36} - Library - Properties + net472 + SharpMap.BusinessObjects.EF6 + SharpMap GIS Map GeoSpatial Business EF6 SharpMap - SharpMap.BusinessObjects.EF6 - v4.0 - 512 - ..\ - true - Client + 1.2.0 + SharpMap - Team + EF6 business objects to work with SharpMap + true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll - - - ..\packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll - - - ..\packages\EntityFramework.6.0.2\lib\net40\EntityFramework.dll - - - ..\packages\EntityFramework.6.0.2\lib\net40\EntityFramework.SqlServer.dll - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - - - True - ..\packages\Microsoft.SqlServer.Types.11.0.1\lib\net20\Microsoft.SqlServer.Types.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\NetTopologySuite.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - - - ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\PowerCollections.dll - - - ..\packages\ProjNET4GeoAPI.1.3.0.3\lib\net40-client\ProjNet.dll - - - ..\packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll - - - - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.dll - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.Linq.dll - - - - - - - - + - - - - - - - - - - - - - Designer + + True + - - - - - SqlServerTypes\x64\msvcr100.dll - Always - - - SqlServerTypes\x64\SqlServerSpatial110.dll - Always - - - SqlServerTypes\x86\msvcr100.dll - Always - - - SqlServerTypes\x86\SqlServerSpatial110.dll - Always - - - - Always - - - Always - + - + + - - {ac492306-4594-4e1e-a7b4-8982937061f8} - SharpMap.BusinessObjects - + - - - \ No newline at end of file + + diff --git a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/ImportFromFolder.cs b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/ImportFromFolder.cs index c5378ff..d863b74 100644 --- a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/ImportFromFolder.cs +++ b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/ImportFromFolder.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright © 2017 - Felix Obermaier, Ingenieurgruppe IVV GmbH & Co. KG * * This file is part of SharpMap.BusinessObjects.MongoDB.Gtfs. @@ -77,11 +77,11 @@ static MongoClient GetLocalClient() } } - public static void Import(DirectoryInfo directory) + public static async Task Import(DirectoryInfo directory) { var client = GetClient(); - client.GetServer().DropDatabase(directory.Name); - var database = client.GetServer().GetDatabase(directory.Name); + await client.DropDatabaseAsync(directory.Name); + var database = client.GetDatabase(directory.Name); // UintIdGenerator.SetKeyTracker(database.GetCollection("uintkeys")); @@ -112,146 +112,162 @@ public static void Import(DirectoryInfo directory) /// /// The mongo database /// The file information - private delegate void ImportToMongoDb(MongoDatabase db, FileInfo fi); + private delegate Task ImportToMongoDb(IMongoDatabase db, FileInfo fi); - private static void ImportOptional(object param) + private static async Task ImportOptional(object param) { var paras = (object[])param; var fileInfo = (FileInfo[])paras[1]; if (fileInfo != null && fileInfo.Length > 0) { var action = (ImportToMongoDb) paras[2]; - var database = (MongoDatabase)paras[0]; + var database = (IMongoDatabase)paras[0]; action(database, fileInfo[0]); } } - private static void ImportFeedInfo(MongoDatabase database, FileInfo getFeedInfo) + private static async Task ImportFeedInfo(IMongoDatabase database, FileInfo getFeedInfo) { var feedInfo = database.GetCollection(getFeedInfo.Name); - feedInfo.InsertBatch(Associator.Read(new StreamReader(getFeedInfo.OpenRead()))); + await feedInfo.InsertManyAsync(Associator.Read(new StreamReader(getFeedInfo.OpenRead()))); } - private static void ImportTransfer(MongoDatabase database, FileInfo getTransfer) + private static async Task ImportTransfer(IMongoDatabase database, FileInfo getTransfer) { var shape = database.GetCollection(getTransfer.Name); - shape.InsertBatch(Associator.Read(new StreamReader(getTransfer.OpenRead()))); - shape.CreateIndex("from_stop_id", "to_stop_id"); + await shape.InsertManyAsync(Associator.Read(new StreamReader(getTransfer.OpenRead()))); + + var bldr = Builders.IndexKeys; + await shape.Indexes.CreateOneAsync(new CreateIndexModel( + bldr.Combine(bldr.Ascending(t => t.FromStopId), + bldr.Ascending(t => t.ToStopId)))); } - private static void ImportFrequency(MongoDatabase database, FileInfo getFrequency) + private static async Task ImportFrequency(IMongoDatabase database, FileInfo getFrequency) { var shape = database.GetCollection(getFrequency.Name); - shape.InsertBatch(Associator.Read(new StreamReader(getFrequency.OpenRead()))); - shape.CreateIndex("trip_id"); + await shape.InsertManyAsync(Associator.Read(new StreamReader(getFrequency.OpenRead()))); + await shape.Indexes.CreateOneAsync(new CreateIndexModel( + Builders.IndexKeys.Ascending(t => t.TripId))); } - private static void ImportShape(MongoDatabase database, FileInfo getShape) + private static async Task ImportShape(IMongoDatabase database, FileInfo getShape) { var shape = database.GetCollection(getShape.Name); - shape.InsertBatch(Associator.Read(new StreamReader(getShape.OpenRead()))); - shape.CreateIndex("shape_id", "shape_sequence"); + await shape.InsertManyAsync(Associator.Read(new StreamReader(getShape.OpenRead()))); + var bldr = Builders.IndexKeys; + await shape.Indexes.CreateOneAsync(new CreateIndexModel( + bldr.Combine(bldr.Ascending(t => t.ShapeID), + bldr.Ascending(t => t.ShapePointSequence)))); } - private static void ImportFareRule(MongoDatabase database, FileInfo getFareRule) + private static async Task ImportFareRule(IMongoDatabase database, FileInfo getFareRule) { - var fareAttribute = database.GetCollection(getFareRule.Name); - fareAttribute.InsertBatch(Associator.Read(new StreamReader(getFareRule.OpenRead()))); - fareAttribute.CreateIndex("fare_id", "route_id"); + var fareRule = database.GetCollection(getFareRule.Name); + await fareRule.InsertManyAsync(Associator.Read(new StreamReader(getFareRule.OpenRead()))); + var bldr = Builders.IndexKeys; + await fareRule.Indexes.CreateOneAsync(new CreateIndexModel( + bldr.Combine(bldr.Ascending(t => t.FareId), bldr.Ascending(t => t.RouteId)))); } - private static void ImportFareAttribute(MongoDatabase database, FileInfo getFareAttribute) + private static async Task ImportFareAttribute(IMongoDatabase database, FileInfo getFareAttribute) { var fareAttribute = database.GetCollection(getFareAttribute.Name); - fareAttribute.InsertBatch(Associator.Read(new StreamReader(getFareAttribute.OpenRead()))); - fareAttribute.CreateIndex("fare_id"); + await fareAttribute.InsertManyAsync(Associator.Read(new StreamReader(getFareAttribute.OpenRead()))); + await fareAttribute.Indexes.CreateOneAsync(new CreateIndexModel( + Builders.IndexKeys.Ascending(t => t.FareId))); } - private static void ImportCalendarDate(MongoDatabase database, FileInfo getCalenderDate) + private static async Task ImportCalendarDate(IMongoDatabase database, FileInfo getCalenderDate) { - var calendar = database.GetCollection("calendar_date"); - calendar.InsertBatch(Associator.Read(new StreamReader(getCalenderDate.OpenRead()))); - calendar.CreateIndex("service_id"); + var calendarDate = database.GetCollection("calendar_date"); + await calendarDate.InsertManyAsync(Associator.Read(new StreamReader(getCalenderDate.OpenRead()))); + await calendarDate.Indexes.CreateOneAsync(new CreateIndexModel( + Builders.IndexKeys.Ascending(t => t.ServiceId))); } - private static void ImportCalendar(MongoDatabase database, FileInfo getFile) + private static async Task ImportCalendar(IMongoDatabase database, FileInfo getFile) { var calendar = database.GetCollection("calendar"); - calendar.InsertBatch(Associator.Read(new StreamReader(getFile.OpenRead()))); - calendar.CreateIndex("service_id"); + await calendar.InsertManyAsync(Associator.Read(new StreamReader(getFile.OpenRead()))); + await calendar.Indexes.CreateOneAsync(new CreateIndexModel( + Builders.IndexKeys.Ascending(t => t.ServiceID))); } - private static void ImportStopTimes(object param) + private static async Task ImportStopTimes(object param) { var paras = (object[])param; - var database = (MongoDatabase)paras[0]; + var database = (IMongoDatabase)paras[0]; var fileInfo = (FileInfo)paras[1]; - ImportStopTimes(database, fileInfo); + await ImportStopTimes(database, fileInfo); } - private static void ImportStopTimes(MongoDatabase database, FileInfo getFile) + private static async Task ImportStopTimes(IMongoDatabase database, FileInfo getFile) { var stopTimes = database.GetCollection("stop_times"); - stopTimes.InsertBatch(Associator.Read(new StreamReader(getFile.OpenRead()))); - stopTimes.CreateIndex("trip_id"); - stopTimes.CreateIndex("trip_id", "stop_id", "stop_sequence"); + await stopTimes.InsertManyAsync(Associator.Read(new StreamReader(getFile.OpenRead()))); + var bldr = Builders.IndexKeys; + await stopTimes.Indexes.CreateOneAsync(new CreateIndexModel(bldr.Ascending(t => t.TripId))); + await stopTimes.Indexes.CreateOneAsync(new CreateIndexModel(bldr.Combine( + bldr.Ascending(t => t.TripId), bldr.Ascending(t => t.StopId), + bldr.Ascending(t => t.StopSequence)))); } - private static void ImportRoute(object param) + private static async Task ImportRoute(object param) { var paras = (object[])param; - var database = (MongoDatabase)paras[0]; + var database = (IMongoDatabase)paras[0]; var fileInfo = (FileInfo)paras[1]; - ImportRoute(database, fileInfo); + await ImportRoute(database, fileInfo); } - private static void ImportRoute(MongoDatabase database, FileInfo fileInfo) + private static async Task ImportRoute(IMongoDatabase database, FileInfo fileInfo) { - var routes = database.GetCollection("routes"); - routes.InsertBatch(Associator.Read(new StreamReader(fileInfo.OpenRead()))); + var routes = database.GetCollection("routes"); + await routes.InsertManyAsync(Associator.Read(new StreamReader(fileInfo.OpenRead()))); } - private static void ImportTrip(object param) + private static async Task ImportTrip(object param) { var paras = (object[])param; - var database = (MongoDatabase)paras[0]; + var database = (IMongoDatabase)paras[0]; var fileInfo = (FileInfo)paras[1]; - ImportTrip(database, fileInfo); + await ImportTrip(database, fileInfo); } - private static void ImportTrip(MongoDatabase database, FileInfo fileInfo) + private static async Task ImportTrip(IMongoDatabase database, FileInfo fileInfo) { - var routes = database.GetCollection("trips"); - routes.InsertBatch(Associator.Read(new StreamReader(fileInfo.OpenRead()))); + var routes = database.GetCollection("trips"); + await routes.InsertManyAsync(Associator.Read(new StreamReader(fileInfo.OpenRead()))); } public static Regex Csv { get { return new Regex("(?<=^|,)(\"(?:[^\"]|\"\")*\"|[^,]*)"); } } - private static void ImportStop(object param) + private static async Task ImportStop(object param) { var paras = (object[]) param; - var database = (MongoDatabase) paras[0]; + var database = (IMongoDatabase) paras[0]; var fileInfo = (FileInfo) paras[1]; - ImportStop(database,fileInfo); + await ImportStop(database,fileInfo); } - private static void ImportStop(MongoDatabase database, FileInfo fileInfo) + private static async Task ImportStop(IMongoDatabase database, FileInfo fileInfo) { var stops = database.GetCollection("stops"); - stops.InsertBatch(Associator.Read(new StreamReader(fileInfo.OpenRead()))); - stops.CreateIndex("StopId"); - stops.CreateIndex("StopLatLon"); + await stops.InsertManyAsync(Associator.Read(new StreamReader(fileInfo.OpenRead()))); + await stops.Indexes.CreateOneAsync(new CreateIndexModel(Builders.IndexKeys.Ascending(t => t.StopId))); + await stops.Indexes.CreateOneAsync(new CreateIndexModel(Builders.IndexKeys.Ascending(t => t.StopLatLon))); } - private static void ImportAgency(object param) + private static async Task ImportAgency(object param) { var paras = (object[]) param; - var database = (MongoDatabase)paras[0]; + var database = (IMongoDatabase)paras[0]; var fileInfo = (FileInfo)paras[1]; - ImportAgency(database, fileInfo); + await ImportAgency(database, fileInfo); } - private static void ImportAgency(MongoDatabase database, FileInfo fileInfo) + private static async Task ImportAgency(IMongoDatabase database, FileInfo fileInfo) { var agencies = database.GetCollection("agency"); - agencies.InsertBatch(Associator.Read(new StreamReader(fileInfo.OpenRead()))); + await agencies.InsertManyAsync(Associator.Read(new StreamReader(fileInfo.OpenRead()))); } @@ -269,4 +285,4 @@ private static void ImportAgency(MongoDatabase database, FileInfo fileInfo) // agencies.InsertBatch(Associator.Read(new StreamReader(fileInfo.OpenRead()))); //} } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/UintIdGenerator.cs b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/UintIdGenerator.cs index 9a67531..6294bae 100644 --- a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/UintIdGenerator.cs +++ b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Gtfs/Import/UintIdGenerator.cs @@ -1,5 +1,5 @@ /* - * Copyright © 2017 - Felix Obermaier, Ingenieurgruppe IVV GmbH & Co. KG + * Copyright © 2017 - Felix Obermaier, Ingenieurgruppe IVV GmbH & Co. KG * * This file is part of SharpMap.BusinessObjects.MongoDB.Gtfs. * @@ -30,9 +30,9 @@ namespace SharpMap.Data.Providers.Business.MongoDB.Gtfs.Import internal class UintIdGenerator : IIdGenerator { private static readonly object Lock = new object(); - private static MongoCollection _uintKeyTracker; + private static IMongoCollection _uintKeyTracker; - public static void SetKeyTracker(MongoCollection keyTracker) + public static void SetKeyTracker(IMongoCollection keyTracker) { if (_uintKeyTracker != null) throw new InvalidOperationException(); @@ -47,22 +47,23 @@ public UintIdGenerator() public object GenerateId(object container, object document) { - var mc = container as MongoCollection; - if (mc == null) + if (!(container is IMongoCollection mc)) throw new ArgumentException("container must be a mongo collection"); - UintKeyTracker keyTracker = null; + string mcName = mc.CollectionNamespace.FullName; + var filter = Builders.Filter.Exists(t => t.CollectionName == mcName); Monitor.Enter(Lock); - keyTracker = _uintKeyTracker.FindOneByIdAs(mc.Name); + var keyTracker = _uintKeyTracker.Find(filter).FirstOrDefault(); if (keyTracker != null) { keyTracker.LastKey++; + _uintKeyTracker.ReplaceOne(filter, keyTracker); } else { - keyTracker = new UintKeyTracker {CollectionName = mc.Name, LastKey = 1}; + keyTracker = new UintKeyTracker {CollectionName = mc.CollectionNamespace.CollectionName, LastKey = 1}; + _uintKeyTracker.InsertOne(keyTracker); } - _uintKeyTracker.Save(keyTracker); Monitor.Exit(Lock); return keyTracker.LastKey; @@ -84,4 +85,4 @@ internal class UintKeyTracker public uint LastKey { get; set; } } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Properties/AssemblyInfo.cs b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Properties/AssemblyInfo.cs deleted file mode 100644 index 7bba97c..0000000 --- a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("SharpMap.Business.MongoDB.Gtfs")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SharpMap.Business.MongoDB.Gtfs")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("9cd68fa7-634b-4917-a551-d4bb53ddd3f1")] - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/SharpMap.BusinessObjects.MongoDB.Gtfs.csproj b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/SharpMap.BusinessObjects.MongoDB.Gtfs.csproj index 111cfc9..54528b6 100644 --- a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/SharpMap.BusinessObjects.MongoDB.Gtfs.csproj +++ b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/SharpMap.BusinessObjects.MongoDB.Gtfs.csproj @@ -1,157 +1,30 @@ - - - + + - Debug - AnyCPU - {513BE777-DCCE-43A1-A727-F521C570BCFD} - Library - Properties + netStandard2.0 + SharpMap.BusinessObjects.MongoDB.Gtfs + SharpMap GIS Map GeoSpatial Business MongoDB Gtfs SharpMap.Data.Providers.Business.MongoDB - SharpMap.BusinessObjects.MongoDB.Gtfs - v4.0 - 512 - ..\ - true - Client + 1.2.0 + SharpMap - Team + MongoDB business objects to work with SharpMap + false + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll - - - ..\packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - - - ..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll - - - False - ..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\NetTopologySuite.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - - - ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\PowerCollections.dll - - - ..\packages\ProjNET4GeoAPI.1.3.0.3\lib\net40-client\ProjNet.dll - - - ..\packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll - - - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.dll - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.Linq.dll - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - {210f7e37-648c-426b-a0c4-101fdcb28362} - SharpMap.BusinessObjects.MongoDB - - - {ac492306-4594-4e1e-a7b4-8982937061f8} - SharpMap.BusinessObjects - + + True + + + - - - Designer - + + - - Always - - - Always - + - - - \ No newline at end of file + + diff --git a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/app.config b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/app.config deleted file mode 100644 index 2f6c846..0000000 --- a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/packages.config b/src/SharpMap.BusinessObjects.MongoDB.Gtfs/packages.config deleted file mode 100644 index 83645ac..0000000 --- a/src/SharpMap.BusinessObjects.MongoDB.Gtfs/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/SharpMap.BusinessObjects.MongoDB/Data/Providers/Business/MongoDbBusinessObjectSource.cs b/src/SharpMap.BusinessObjects.MongoDB/Data/Providers/Business/MongoDbBusinessObjectSource.cs index 62b4013..c595769 100644 --- a/src/SharpMap.BusinessObjects.MongoDB/Data/Providers/Business/MongoDbBusinessObjectSource.cs +++ b/src/SharpMap.BusinessObjects.MongoDB/Data/Providers/Business/MongoDbBusinessObjectSource.cs @@ -20,7 +20,7 @@ using GeoAPI.Geometries; using MongoDB.Bson.Serialization; using MongoDB.Driver; -using MongoDB.Driver.Builders; +//using MongoDB.Driver.Builders; using MongoDB.Driver.GeoJsonObjectModel; using SharpMap.Converters; @@ -34,7 +34,7 @@ namespace SharpMap.Data.Providers.Business public abstract class MongoDbBusinessObjectSource : BaseBusinessObjectSource where TCoordinate: GeoJsonCoordinates { - private readonly MongoCollection _collection; + private readonly IMongoCollection _collection; protected readonly GeoJsonConverter Converter; private MongoDbBusinessObjectSource(GeoJsonConverter converter) @@ -66,7 +66,7 @@ protected MongoDbBusinessObjectSource(GeoJsonConverter converter, s private MongoDbBusinessObjectSource(GeoJsonConverter converter, MongoClient mongoClient, string database, string collection) :this(converter) { - var mongoDatabase = mongoClient.GetServer().GetDatabase(database); + var mongoDatabase = mongoClient.GetDatabase(database); _collection = mongoDatabase.GetCollection(collection); } @@ -80,15 +80,19 @@ public override Envelope GetExtents() return CachedExtents; var extent = new Envelope(); - foreach (var t in _collection.FindAll()) - extent.ExpandToInclude(GetGeometry(t).EnvelopeInternal); + var crsr = _collection.FindSync(Builders.Filter.Empty); + while (crsr.MoveNext()) + { + foreach (var itm in crsr.Current) + extent.ExpandToInclude(GetGeometry(itm).EnvelopeInternal); + } return CachedExtents = extent; } public override IEnumerable Select(Envelope box) { box = GetExtents().Intersection(box); - return _collection.Find(BuildEnvelopeQuery(box)); + return _collection.Find(BuildEnvelopeQuery(box)).ToEnumerable(); } /// @@ -96,7 +100,7 @@ public override IEnumerable Select(Envelope box) /// /// /// - protected abstract IMongoQuery BuildEnvelopeQuery(Envelope box); + protected abstract FilterDefinition BuildEnvelopeQuery(Envelope box); /// /// Select a set of features based on @@ -117,7 +121,7 @@ public override IEnumerable Select(IGeometry geom) /// public override T Select(uint id) { - return _collection.FindOneById(id); + return _collection.FindSync(Builders.Filter.Eq(t => GetId(t) == id, true)).FirstOrDefault(); } /// @@ -128,7 +132,9 @@ public override void Update(IEnumerable businessObjects) { foreach (var businessObject in businessObjects) { - _collection.Save(businessObject); + uint id = GetId(businessObject); + var filter = Builders.Filter.Eq(t => GetId(t), id); + _collection.ReplaceOne(filter, businessObject); } } @@ -140,8 +146,9 @@ public override void Delete(IEnumerable businessObjects) { foreach (var businessObject in businessObjects) { - var query = Query.EQ(t => GetId(t), GetId(businessObject)); - _collection.Remove(query); + uint id = GetId(businessObject); + var query = Builders.Filter.Eq(t => GetId(t), id); + _collection.DeleteOne(query); } } @@ -151,7 +158,7 @@ public override void Delete(IEnumerable businessObjects) /// The features that need to be inserted public override void Insert(IEnumerable businessObjects) { - _collection.InsertBatch(businessObjects); + _collection.InsertMany(businessObjects); } /// @@ -159,7 +166,7 @@ public override void Insert(IEnumerable businessObjects) /// public override int Count { - get { return (int)_collection.Count(); } + get { return (int)_collection.CountDocuments(Builders.Filter.Empty); } } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.MongoDB/Properties/AssemblyInfo.cs b/src/SharpMap.BusinessObjects.MongoDB/Properties/AssemblyInfo.cs deleted file mode 100644 index bad5711..0000000 --- a/src/SharpMap.BusinessObjects.MongoDB/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("SharpMap.Business.MongoDB")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SharpMap.Business.MongoDB")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("ebe82f86-1088-4611-9973-f57557a1b18e")] - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SharpMap.BusinessObjects.MongoDB/SharpMap.BusinessObjects.MongoDB.csproj b/src/SharpMap.BusinessObjects.MongoDB/SharpMap.BusinessObjects.MongoDB.csproj index de9f4bf..dfe7e86 100644 --- a/src/SharpMap.BusinessObjects.MongoDB/SharpMap.BusinessObjects.MongoDB.csproj +++ b/src/SharpMap.BusinessObjects.MongoDB/SharpMap.BusinessObjects.MongoDB.csproj @@ -1,135 +1,29 @@ - - - + + - Debug - AnyCPU - {210F7E37-648C-426B-A0C4-101FDCB28362} - Library - Properties + netStandard2.0 + SharpMap.BusinessObjects.MongoDB + SharpMap GIS Map GeoSpatial Business MongoDB SharpMap - SharpMap.BusinessObjects.MongoDB - v4.0 - 512 - Client - ..\ - true + 1.2.0 + SharpMap - Team + MongoDB business objects to work with SharpMap + true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll - - - ..\packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - - - ..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll - True - - - ..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\NetTopologySuite.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - - - ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\PowerCollections.dll - - - ..\packages\ProjNET4GeoAPI.1.3.0.3\lib\net40-client\ProjNet.dll - - - ..\packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll - - - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.dll - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.Linq.dll - - - - - - - - - - - Code - - - - + - - - Designer + + True + + - - {ac492306-4594-4e1e-a7b4-8982937061f8} - SharpMap.BusinessObjects - + + - - Always - - - Always - + - - - \ No newline at end of file + + diff --git a/src/SharpMap.BusinessObjects.Tests/MongoDB/Gtfs/GtfsImportTest.cs b/src/SharpMap.BusinessObjects.Tests/MongoDB/Gtfs/GtfsImportTest.cs index 5e4dc64..5e78c40 100644 --- a/src/SharpMap.BusinessObjects.Tests/MongoDB/Gtfs/GtfsImportTest.cs +++ b/src/SharpMap.BusinessObjects.Tests/MongoDB/Gtfs/GtfsImportTest.cs @@ -1,9 +1,7 @@ -using NUnit.Framework; +using NUnit.Framework; using System; -using System.Globalization; using System.IO; -using ICSharpCode.SharpZipLib.Core; -using ICSharpCode.SharpZipLib.Zip; +using System.IO.Compression; using SharpMap.Data.Providers.Business.MongoDB.Gtfs.Import; namespace SharpMap.Business.Tests.MongoDB.Gtfs @@ -31,7 +29,7 @@ public void TestImport(string path) try { var di = new DirectoryInfo(path); - ImportFromFolder.Import(di); + ImportFromFolder.Import(di).GetAwaiter().GetResult(); } catch (Exception e) { @@ -54,45 +52,8 @@ private string ExtractZip(string zipPath) Directory.Delete(workingDataDirectory, true); Directory.CreateDirectory(workingDataDirectory); + ZipFile.ExtractToDirectory(zipPath, workingDataDirectory); - ZipFile zf = null; - try - { - var fs = File.OpenRead(workingZipPath); - zf = new ZipFile(fs); - - foreach (ZipEntry zipEntry in zf) - { - if (!zipEntry.IsFile) - { - continue; // Ignore directories - } - String entryFileName = zipEntry.Name; - // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName); - // Optionally match entrynames against a selection list here to skip as desired. - // The unpacked length is available in the zipEntry.Size property. - - var buffer = new byte[4096]; // 4K is optimum - var zipStream = zf.GetInputStream(zipEntry); - - // Manipulate the output filename here as desired. - var fullZipToPath = Path.Combine(workingDataDirectory, entryFileName); - - // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size - // of the file, but does not waste memory. - // The "using" will close the stream even if an exception occurs. - using (var streamWriter = File.Create(fullZipToPath)) - StreamUtils.Copy(zipStream, streamWriter, buffer); - } - } - finally - { - if (zf != null) - { - zf.IsStreamOwner = true; // Makes close also shut the underlying stream - zf.Close(); // Ensure we release resources - } - } return workingDataDirectory; } @@ -106,4 +67,4 @@ private void CopyToWorkingDirectory(string path) } } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.Tests/MongoDB/MongoDbTests.cs b/src/SharpMap.BusinessObjects.Tests/MongoDB/MongoDbTests.cs index 04e3957..a2d4461 100644 --- a/src/SharpMap.BusinessObjects.Tests/MongoDB/MongoDbTests.cs +++ b/src/SharpMap.BusinessObjects.Tests/MongoDB/MongoDbTests.cs @@ -18,6 +18,8 @@ namespace SharpMap.Business.Tests.MongoDB /// public class MongoDbTests { + private static readonly ILog Log = LogManager.GetLogger(); + private MongoClient _client; private const string TestConnection = "mongodb://localhost"; @@ -32,16 +34,15 @@ static MongoClient GetClient() try { var client = new MongoClient(TestConnection); - var server = client.GetServer(); - foreach (var dbNames in server.GetDatabaseNames()) + foreach (var dbNames in client.ListDatabaseNames().ToEnumerable()) { - LogManager.GetCurrentClassLogger().Debug(fmh => fmh("{0}", dbNames)); + Log.Debug(fmh => fmh("{0}", dbNames)); } return client; } catch (Exception ex) { - LogManager.GetCurrentClassLogger().Debug(fmh => fmh("MongoDB Server not found or running")); + Log.Debug(fmh => fmh("MongoDB Server not found or running")); } return null; } @@ -69,25 +70,32 @@ public void SetUp() if (_client == null) throw new IgnoreException("Creation of MongoClient failed"); - var server = _client.GetServer(); + /* + //var server = _client.Settings.; if (server.BuildInfo != null) { if (server.BuildInfo.Version < new Version(2, 4)) throw new IgnoreException("MongoDB server must have at least version 2.4"); } - - if (server.DatabaseExists(TestDatabase)) - server.DropDatabase(TestDatabase); + */ + if (_client.GetDatabase(TestDatabase) != null) + _client.DropDatabase(TestDatabase); GeoAPI.GeometryServiceProvider.Instance = NetTopologySuite.NtsGeometryServices.Instance; - CreatePoIDatabase(server); + CreatePoIDatabase(_client); } - private static void CreatePoIDatabase(MongoServer server) + private static void CreatePoIDatabase(IMongoClient client) { - var db = server.GetDatabase(TestDatabase); - if (!db.CreateCollection("Items").Ok) - throw new IgnoreException("Faild to create collection items"); + var db = client.GetDatabase(TestDatabase); + try + { + db.CreateCollection("Items"); + } + catch (Exception e) + { + throw new IgnoreException("Faild to create collection items", e); + } //Assign the converter PoI.Converter = GeoJsonConverter.Converter2D; @@ -96,7 +104,7 @@ private static void CreatePoIDatabase(MongoServer server) var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326); for (uint oid = 1; oid <= 1000; oid++) { - col.Insert(RndPoi(ref oid, factory)); + col.InsertOne(RndPoi(ref oid, factory)); } @@ -181,4 +189,4 @@ private static double RndY() #endregion } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.Tests/MongoDB/PoIRepository.cs b/src/SharpMap.BusinessObjects.Tests/MongoDB/PoIRepository.cs index 5aa7786..96bfca6 100644 --- a/src/SharpMap.BusinessObjects.Tests/MongoDB/PoIRepository.cs +++ b/src/SharpMap.BusinessObjects.Tests/MongoDB/PoIRepository.cs @@ -1,6 +1,6 @@ using GeoAPI.Geometries; +using MongoDB.Bson.Serialization; using MongoDB.Driver; -using MongoDB.Driver.Builders; using MongoDB.Driver.GeoJsonObjectModel; using SharpMap.Converters; using SharpMap.Data.Providers.Business; @@ -20,10 +20,10 @@ public PoIRepository(GeoJsonConverter converter, string co } - protected override IMongoQuery BuildEnvelopeQuery(Envelope box) + protected override FilterDefinition BuildEnvelopeQuery(Envelope box) { - //return Query.GeoIntersects(t => t.BsonGeometry, Converter.ToPolygon(box)); - return Query.WithinRectangle(t => t.BsonGeometry, box.MinX, box.MinY, box.MaxX, box.MaxY); + //return Query.GeoIntersects(t => t.BsonGeometry, Converter.ToPolygon(box)); + return Builders.Filter.GeoWithinBox(t => t.BsonGeometry, box.MinX, box.MinY, box.MaxX, box.MaxY); } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.Tests/NHibernating/BusinessObjectSource.cs b/src/SharpMap.BusinessObjects.Tests/NHibernating/BusinessObjectSource.cs index 59d6dae..baf70a4 100644 --- a/src/SharpMap.BusinessObjects.Tests/NHibernating/BusinessObjectSource.cs +++ b/src/SharpMap.BusinessObjects.Tests/NHibernating/BusinessObjectSource.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using GeoAPI.Geometries; using NHibernate; using NHibernate.Criterion; @@ -15,7 +15,7 @@ public BusinessObjectSource() { _title = typeof (T).Name; } - private static ISession GetSession() + private static NHibernate.ISession GetSession() { return SessionProvider.SessionFactory.OpenSession(); } @@ -128,4 +128,4 @@ public override Envelope GetExtents() return _cached; } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.Tests/NHibernating/GeometryUserType.cs b/src/SharpMap.BusinessObjects.Tests/NHibernating/GeometryUserType.cs index f11f74f..5615089 100644 --- a/src/SharpMap.BusinessObjects.Tests/NHibernating/GeometryUserType.cs +++ b/src/SharpMap.BusinessObjects.Tests/NHibernating/GeometryUserType.cs @@ -1,9 +1,11 @@ -using System; +using System; using System.Data; +using System.Data.Common; using GeoAPI.Geometries; using GeoAPI.IO; using NetTopologySuite.IO; using NHibernate; +using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -25,7 +27,7 @@ public int GetHashCode(object x) return x.GetHashCode(); } - public object NullSafeGet(IDataReader rs, string[] names, object owner) + public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor implementor, object owner) { var value = rs.GetValue(rs.GetOrdinal(names[0])); if (value == DBNull.Value) @@ -34,10 +36,10 @@ public object NullSafeGet(IDataReader rs, string[] names, object owner) return Reader.Read((byte[]) value); } - public void NullSafeSet(IDbCommand cmd, object value, int index) + public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor implementor) { var geom = (IGeometry) value; - NHibernateUtil.Binary.NullSafeSet(cmd, Writer.Write(geom), index); + NHibernateUtil.Binary.NullSafeSet(cmd, Writer.Write(geom), index, implementor); } public object DeepCopy(object value) @@ -71,4 +73,4 @@ public bool IsMutable get { return true; } } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.Tests/NHibernating/NHibernateTests.cs b/src/SharpMap.BusinessObjects.Tests/NHibernating/NHibernateTests.cs index 0dc4dbd..594555f 100644 --- a/src/SharpMap.BusinessObjects.Tests/NHibernating/NHibernateTests.cs +++ b/src/SharpMap.BusinessObjects.Tests/NHibernating/NHibernateTests.cs @@ -1,9 +1,8 @@ -using System; +using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; -using System.Windows.Forms; using GeoAPI.Geometries; using NUnit.Framework; using SharpMap.Data; @@ -119,7 +118,7 @@ public void TestGetMap() { using (var m = new Map(new Size(720, 360))) { - VectorRenderer.SizeOfString = (g, s, f) => TextRenderer.MeasureText(g, s, f); + //VectorRenderer.SizeOfString = (g, s, f) => TextRenderer.MeasureText(g, s, f); m.BackColor = Color.White; IProvider p = null; @@ -152,4 +151,4 @@ public void TestGetMap() } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects.Tests/Properties/AssemblyInfo.cs b/src/SharpMap.BusinessObjects.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index c5a446f..0000000 --- a/src/SharpMap.BusinessObjects.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("SharpMap.Data.Providers.Business.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SharpMap.Data.Providers.Business.Tests")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("518190cc-573f-47a1-b46a-daf97cd4ab9b")] - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SharpMap.BusinessObjects.Tests/SharpMap.BusinessObjects.Tests.csproj b/src/SharpMap.BusinessObjects.Tests/SharpMap.BusinessObjects.Tests.csproj index 36a0ab2..c19a177 100644 --- a/src/SharpMap.BusinessObjects.Tests/SharpMap.BusinessObjects.Tests.csproj +++ b/src/SharpMap.BusinessObjects.Tests/SharpMap.BusinessObjects.Tests.csproj @@ -1,207 +1,29 @@ - - - + + - Debug - AnyCPU - {6BB66868-62EA-49C7-A6F4-06B87E2BDE6D} - Library - Properties + net472 + SharpMap.BusinessObjects.Tests SharpMap.Business.Tests - SharpMap.BusinessObjects.Tests - v4.0 - 512 - - - ..\ - true + 1.2.0 + SharpMap - Team + Tests around business objects that should work with SharpMap + + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - x86 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll - - - ..\packages\Castle.Core.2.5.2\lib\NET35\Castle.Core.dll - - - ..\packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll - - - ..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.dll - - - ..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.SqlServer.dll - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - - ..\packages\Iesi.Collections.3.1.0.4000\lib\Net35\Iesi.Collections.dll - - - ..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll - - - ..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\NetTopologySuite.dll - - - ..\packages\NetTopologySuite.IO.GeoJSON.1.13.3\lib\net40-client\NetTopologySuite.IO.GeoJSON.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - - - ..\packages\NetTopologySuite.IO.SpatiaLite.1.13.2\lib\net40-client\NetTopologySuite.IO.SpatiaLite.dll - - - ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - - ..\packages\NHibernate.3.1.0.4000\lib\Net35\NHibernate.dll - - - ..\packages\NHibernate.Castle.3.1.0.4000\lib\Net35\NHibernate.ByteCode.Castle.dll - - - ..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\PowerCollections.dll - - - ..\packages\ProjNET4GeoAPI.1.3.0.3\lib\net40-client\ProjNet.dll - - - ..\packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll - - - - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.dll - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.Linq.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {f2ef6114-b690-45a6-bdad-4f362ef0bc36} - SharpMap.BusinessObjects.EF6 - - - {513be777-dcce-43a1-a727-f521c570bcfd} - SharpMap.BusinessObjects.MongoDB.Gtfs - - - {210f7e37-648c-426b-a0c4-101fdcb28362} - SharpMap.BusinessObjects.MongoDB - - - {ac492306-4594-4e1e-a7b4-8982937061f8} - SharpMap.BusinessObjects - - - - - - - PreserveNewest - - - PreserveNewest - - + - - Always - - - Always - - - Always - + + + + + + - - Designer - + + + + - - - \ No newline at end of file + + diff --git a/src/SharpMap.BusinessObjects.Tests/app.config b/src/SharpMap.BusinessObjects.Tests/app.config index 5a43a04..eeb9b34 100644 --- a/src/SharpMap.BusinessObjects.Tests/app.config +++ b/src/SharpMap.BusinessObjects.Tests/app.config @@ -1,4 +1,4 @@ - + @@ -7,18 +7,6 @@
- - - - - - - - - - - - diff --git a/src/SharpMap.BusinessObjects.sln b/src/SharpMap.BusinessObjects.sln index 50dd8f5..ce1e6f1 100644 --- a/src/SharpMap.BusinessObjects.sln +++ b/src/SharpMap.BusinessObjects.sln @@ -1,20 +1,21 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26403.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30517.126 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMap.BusinessObjects", "SharpMap.BusinessObjects\SharpMap.BusinessObjects.csproj", "{AC492306-4594-4E1E-A7B4-8982937061F8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpMap.BusinessObjects", "SharpMap.BusinessObjects\SharpMap.BusinessObjects.csproj", "{AC492306-4594-4E1E-A7B4-8982937061F8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMap.BusinessObjects.EF6", "SharpMap.BusinessObjects.EF6\SharpMap.BusinessObjects.EF6.csproj", "{F2EF6114-B690-45A6-BDAD-4F362EF0BC36}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpMap.BusinessObjects.EF6", "SharpMap.BusinessObjects.EF6\SharpMap.BusinessObjects.EF6.csproj", "{F2EF6114-B690-45A6-BDAD-4F362EF0BC36}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMap.BusinessObjects.MongoDB", "SharpMap.BusinessObjects.MongoDB\SharpMap.BusinessObjects.MongoDB.csproj", "{210F7E37-648C-426B-A0C4-101FDCB28362}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpMap.BusinessObjects.MongoDB", "SharpMap.BusinessObjects.MongoDB\SharpMap.BusinessObjects.MongoDB.csproj", "{210F7E37-648C-426B-A0C4-101FDCB28362}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMap.BusinessObjects.MongoDB.Gtfs", "SharpMap.BusinessObjects.MongoDB.Gtfs\SharpMap.BusinessObjects.MongoDB.Gtfs.csproj", "{513BE777-DCCE-43A1-A727-F521C570BCFD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpMap.BusinessObjects.MongoDB.Gtfs", "SharpMap.BusinessObjects.MongoDB.Gtfs\SharpMap.BusinessObjects.MongoDB.Gtfs.csproj", "{513BE777-DCCE-43A1-A727-F521C570BCFD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMap.BusinessObjects.Tests", "SharpMap.BusinessObjects.Tests\SharpMap.BusinessObjects.Tests.csproj", "{6BB66868-62EA-49C7-A6F4-06B87E2BDE6D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpMap.BusinessObjects.Tests", "SharpMap.BusinessObjects.Tests\SharpMap.BusinessObjects.Tests.csproj", "{6BB66868-62EA-49C7-A6F4-06B87E2BDE6D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{3F947150-250D-4662-AA5D-E970C66C0C7B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "General", "General", "{3F947150-250D-4662-AA5D-E970C66C0C7B}" ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props ..\LICENSE = ..\LICENSE ..\README.md = ..\README.md EndProjectSection @@ -49,4 +50,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {62E81D13-A020-4587-8A1A-12D59301F9FA} + EndGlobalSection EndGlobal diff --git a/src/SharpMap.BusinessObjects/Layers/BusinessObjectLayer.cs b/src/SharpMap.BusinessObjects/Layers/BusinessObjectLayer.cs index 22c082d..742f214 100644 --- a/src/SharpMap.BusinessObjects/Layers/BusinessObjectLayer.cs +++ b/src/SharpMap.BusinessObjects/Layers/BusinessObjectLayer.cs @@ -1,4 +1,4 @@ -// Copyright 2014 - Felix Obermaier (www.ivv-aachen.de) +// Copyright 2014 - Felix Obermaier (www.ivv-aachen.de) // // This file is part of SharpMap.BusinessObjects. // SharpMap.BusinessObjects is free software; you can redistribute it and/or modify @@ -25,6 +25,7 @@ using SharpMap.Data; using SharpMap.Data.Providers; using SharpMap.Data.Providers.Business; +using SharpMap.Rendering; using SharpMap.Rendering.Business; using SharpMap.Rendering.Thematics; using SharpMap.Styles; @@ -134,8 +135,7 @@ protected virtual void OnRendererChanged(EventArgs e) { Logger.Info(fmh => fmh("Renderer changed: {0}", _businessObjectRenderer != null ? _businessObjectRenderer.GetType().Name : "null")); - if (RendererChanged != null) - RendererChanged(this, e); + RendererChanged?.Invoke(this, e); } /// @@ -185,7 +185,8 @@ public override Envelope Envelope /// Renders the layer ///
/// Graphics object referenceMap which is rendered - public override void Render(Graphics g, Map map) + /// The area that is affected by the rendering + protected override void Render(Graphics g, MapViewport map, out Rectangle affectedArea) { if (_businessObjectRenderer != null) { @@ -203,9 +204,10 @@ public override void Render(Graphics g, Map map) var env = ToSource(map.Envelope); // Render all objects + Rectangle affected = Rectangle.Empty; foreach (var bo in _source.Select(env)) { - _businessObjectRenderer.Render(bo); + affectedArea.ExpandToInclude(_businessObjectRenderer.Render(bo)); } // Finish rendering @@ -362,4 +364,4 @@ private void OnDeserialized(StreamingContext context) _provider = new BusinessObjectProvider(_source.Title, _source); } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects/Properties/AssemblyInfo.cs b/src/SharpMap.BusinessObjects/Properties/AssemblyInfo.cs deleted file mode 100644 index 26cf00f..0000000 --- a/src/SharpMap.BusinessObjects/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("SharpMap.BusinessObjects")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SharpMap.BusinessObjects")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] - -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("2ff99615-6601-4a6a-8f7a-bdb81bc33e11")] -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: InternalsVisibleTo("SharpMap.BusinessObjects.Tests", AllInternalsVisible = true)] diff --git a/src/SharpMap.BusinessObjects/Properties/AssemblyInfoSupplement.cs b/src/SharpMap.BusinessObjects/Properties/AssemblyInfoSupplement.cs new file mode 100644 index 0000000..6ff2c6b --- /dev/null +++ b/src/SharpMap.BusinessObjects/Properties/AssemblyInfoSupplement.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("SharpMap.BusinessObjects.Tests", AllInternalsVisible = true)] diff --git a/src/SharpMap.BusinessObjects/Rendering/Business/BusinessObjectToImageRenderer.cs b/src/SharpMap.BusinessObjects/Rendering/Business/BusinessObjectToImageRenderer.cs index ba9a614..959b253 100644 --- a/src/SharpMap.BusinessObjects/Rendering/Business/BusinessObjectToImageRenderer.cs +++ b/src/SharpMap.BusinessObjects/Rendering/Business/BusinessObjectToImageRenderer.cs @@ -28,18 +28,24 @@ public abstract class BusinessObjectToImageRenderer : IBusinessObjectRenderer [NonSerialized] private Bitmap _image; + /// + /// A graphics object + /// [NonSerialized] protected Graphics Graphics; + /// + /// A map viewport object + /// [NonSerialized] - protected Map Map; + protected MapViewport Map; /// /// Method to start the rendering of business objects /// /// The graphics object /// The map - public void StartRendering(Graphics g, Map map) + public void StartRendering(Graphics g, MapViewport map) { _image = new Bitmap(map.Size.Width, map.Size.Height, PixelFormat.Format32bppArgb); Graphics = Graphics.FromImage(_image); @@ -57,14 +63,14 @@ public void StartRendering(Graphics g, Map map) /// Method to render each individual business object /// /// The business object to render - public abstract void Render(T businessObject); + public abstract Rectangle Render(T businessObject); /// /// Method to finalize rendering of business objects /// /// The graphics object /// The map - public void EndRendering(Graphics g, Map map) + public void EndRendering(Graphics g, MapViewport map) { // Blit image to map g.DrawImageUnscaled(_image, 0, 0); @@ -82,4 +88,4 @@ public void EndRendering(Graphics g, Map map) /// public Func Transformation { get; set; } } -} \ No newline at end of file +} diff --git a/src/SharpMap.BusinessObjects/Rendering/Business/IBusinessObjectRenderer.cs b/src/SharpMap.BusinessObjects/Rendering/Business/IBusinessObjectRenderer.cs index ecda2b9..02ac84d 100644 --- a/src/SharpMap.BusinessObjects/Rendering/Business/IBusinessObjectRenderer.cs +++ b/src/SharpMap.BusinessObjects/Rendering/Business/IBusinessObjectRenderer.cs @@ -1,4 +1,4 @@ -// Copyright 2014 - Felix Obermaier (www.ivv-aachen.de) +// Copyright 2014 - Felix Obermaier (www.ivv-aachen.de) // // This file is part of SharpMap.BusinessObjects. // SharpMap.BusinessObjects is free software; you can redistribute it and/or modify @@ -32,24 +32,24 @@ public interface IBusinessObjectRenderer /// /// The graphics object /// The map - void StartRendering(Graphics g, Map map); + void StartRendering(Graphics g, MapViewport map); /// /// Method to render each individual business object /// /// The business object to render - void Render(T businessObject); + Rectangle Render(T businessObject); /// /// Method to finalize rendering of business objects /// /// The graphics object /// The map - void EndRendering(Graphics g, Map map); + void EndRendering(Graphics g, MapViewport map); /// /// Gets or sets a value indicating the transformation that is to be applied on the geometry prior to rendering /// Func Transformation { get; set; } - } -} \ No newline at end of file + } +} diff --git a/src/SharpMap.BusinessObjects/SharpMap.BusinessObjects.csproj b/src/SharpMap.BusinessObjects/SharpMap.BusinessObjects.csproj index 01262c8..5a0411f 100644 --- a/src/SharpMap.BusinessObjects/SharpMap.BusinessObjects.csproj +++ b/src/SharpMap.BusinessObjects/SharpMap.BusinessObjects.csproj @@ -1,125 +1,26 @@ - - - + + - Debug - AnyCPU - {AC492306-4594-4E1E-A7B4-8982937061F8} - Library - Properties + netStandard2.0 + SharpMap.BusinessObjects + SharpMap GIS Map GeoSpatial Business SharpMap - SharpMap.BusinessObjects - v4.0 - 512 - ..\ - true - Client + SharpMap - Team + Business objects to work with SharpMap + true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll - - - ..\packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\NetTopologySuite.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - - - ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\PowerCollections.dll - - - ..\packages\ProjNET4GeoAPI.1.3.0.3\lib\net40-client\ProjNet.dll - - - ..\packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll - - - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.dll - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.Linq.dll - - - - - - - - - - - - - - - - - - - - + - - + + + + - - Always - - - Always - + + True + - - - \ No newline at end of file + + + diff --git a/src/SharpMap.BusinessObjects/app.config b/src/SharpMap.BusinessObjects/app.config deleted file mode 100644 index 2f6c846..0000000 --- a/src/SharpMap.BusinessObjects/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/SharpMap.BusinessObjects/packages.config b/src/SharpMap.BusinessObjects/packages.config deleted file mode 100644 index 33d9d20..0000000 --- a/src/SharpMap.BusinessObjects/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/SharpMap.Logo.png b/src/SharpMap.Logo.png new file mode 100644 index 0000000..a1bab0d Binary files /dev/null and b/src/SharpMap.Logo.png differ