From e89bd8e40dca9a6ab2475478de04832a021bfcb1 Mon Sep 17 00:00:00 2001 From: Thomas Buck Date: Tue, 17 Dec 2024 18:54:39 +0000 Subject: [PATCH 1/3] Add a few notes to the readme, change to markdown extension --- Readme.txt => Readme.md | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) rename Readme.txt => Readme.md (81%) diff --git a/Readme.txt b/Readme.md similarity index 81% rename from Readme.txt rename to Readme.md index 5716cfd..1a6d9f0 100644 --- a/Readme.txt +++ b/Readme.md @@ -1,3 +1,70 @@ +# SQLServerSpatialTools for dotnet core + +A very quick fork that modifies the `.csproj` project file to compile under dotnet core 9 on macos, removes the `pfx` code signing bits (which presumably are unsupported - anyone with more time, please feel free to investigate!), and removes the `LRS` code that breaks the build. + +## Compilation + +```shell +git checkout https://github.com/tbbuck/SQLServerSpatialTools-DotnetCore +cd SQLServerSpatialTools-DotnetCore/src +dotnet build +``` + +The resulting `.dll` will be found at `SQLServerSpatialTools-DotnetCore/output/lib/net481/SQLSpatialTools.dll` + +## Installation + +### System +```shell +# copy the file to your MSSQL server however you fancy, and put in an MSSQL-accessible directory, for example: +scp SQLServerSpatialTools-DotnetCore/output/lib/net481/SQLSpatialTools.dll MyFancySqlServer:/tmp +sudo mkdir /opt/mssql-clr/SQLServerSpatialTools-DotnetCore +sudo mv /tmp/SQLServerSpatialTools.dll /opt/mssql-clr/SQLServerSpatialTools-DotnetCore +sudo chown mssql:mssql -R /opt/mssql-clr/SQLServerSpatialTools-DotnetCore +``` + +### SQL Server + +(basically - follow the instructions in `src/SQL Scripts/Register.sql`: + +```sql +-- These first few instructions may not be necessary if you've set up CLRs pbefore +-- Copyright (c) Microsoft Corporation. All rights reserved. +-- Install the SQLSpatialTools assembly and all its functions into the current database + +-- Enabling CLR prior to registering assembly and its related functions. +EXEC sp_configure 'show advanced option', '1'; +RECONFIGURE; +Go + +sp_configure 'clr enabled', 1 ; +GO +RECONFIGURE ; +GO + +EXEC sp_configure 'clr strict security', '0' +RECONFIGURE WITH OVERRIDE; +GO + +-- This is the big important one +CREATE assembly SQLSpatialTools +FROM '/opt/mssql-clr/SQLServerSpatialTools-DotnetCore/SQLSpatialTools.dll' +GO + +--- run the rest of the commands from the Register script, such as: + +CREATE FUNCTION IsValidGeographyFromText ( + @inputWKT NVARCHAR(MAX) + ,@srid INT + ) +RETURNS BIT +AS +EXTERNAL NAME SQLSpatialTools.[SQLSpatialTools.Functions.General.Geography].IsValidGeographyFromText +GO + + +``` + *********************************************************** ** 0: Contents *********************************************************** From b262b7b178030d6fbdef19d6bc11cd235dbe0b83 Mon Sep 17 00:00:00 2001 From: Thomas Buck Date: Tue, 17 Dec 2024 18:55:27 +0000 Subject: [PATCH 2/3] Delete src/Sinks/Geometry/BuidLRSMultiLineSink.cs because it breaks the build --- src/Sinks/Geometry/BuidLRSMultiLineSink.cs | 83 ---------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/Sinks/Geometry/BuidLRSMultiLineSink.cs diff --git a/src/Sinks/Geometry/BuidLRSMultiLineSink.cs b/src/Sinks/Geometry/BuidLRSMultiLineSink.cs deleted file mode 100644 index b620fb5..0000000 --- a/src/Sinks/Geometry/BuidLRSMultiLineSink.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. - -using Microsoft.SqlServer.Types; -using SQLSpatialTools.Utility; -using System; -using System.Text; - -namespace SQLSpatialTools -{ - /// - /// This class implements a geometry sink that builds LRS multiline. - /// Second segment measure is updated with offset difference. - /// - class BuildLRSMultiLineSink : IGeometrySink110 - { - private LRSLine CurrentLine; - public LRSMultiLine MultiLine; - private int Srid; - - public void ScaleMeasure(double offsetMeasure) - { - MultiLine.ScaleMeasure(offsetMeasure); - } - public void TranslateMeasure(double offsetMeasure) - { - MultiLine.TranslateMeasure(offsetMeasure); - } - /// - /// Initializes a new instance of the class. - /// - public BuildLRSMultiLineSink() - { - MultiLine = new LRSMultiLine(); - } - - public void SetSrid(int srid) - { - Srid = srid; - } - - // Start the geometry. - public void BeginGeometry(OpenGisGeometryType type) - { - if (type == OpenGisGeometryType.LineString) - { - CurrentLine = new LRSLine(); - CurrentLine.SetSrid(Srid); - } - } - - // Start the figure. - public void BeginFigure(double x, double y, double? z, double? m) - { - CurrentLine.AddPoint(new LRSPoint(x, y, z, m)); - } - - // This is where the real work is done. - public void AddLine(double x, double y, double? z, double? m) - { - CurrentLine.AddPoint(new LRSPoint(x, y, z, m)); - } - - public void AddCircularArc(double x1, double y1, double? z1, double? m1, double x2, double y2, double? z2, double? m2) - { - throw new Exception("AddCircularArc is not implemented yet in this class"); - } - - // This is a NO-OP - public void EndFigure() - { - MultiLine.AddLine(CurrentLine); - } - - // This is a NO-OP - public void EndGeometry() - { - } - public SqlGeometry ToSqlGeometry() - { - return MultiLine.ToSqlGeometry(); - } - } -} From 6e8aecf13ca0fb614df58c6f597c3373b36fac1f Mon Sep 17 00:00:00 2001 From: Thomas Buck Date: Tue, 17 Dec 2024 18:57:43 +0000 Subject: [PATCH 3/3] Update SQLSpatialTools.csproj to build with dotnet core Sets target framework to net481, referencing Microsoft.NETFramework.ReferenceAssemblies and setting - + + 10.0 + + false + Debug AnyCPU @@ -13,7 +16,7 @@ Properties SQLSpatialTools SQLSpatialTools - v3.5 + net481 512 @@ -45,7 +48,6 @@ DEBUG;TRACE prompt 4 - AllRules.ruleset full @@ -58,17 +60,10 @@ AllRules.ruleset true - - true - - - ..\SpatialTools.pfx - - - False - ..\packages\Microsoft.SqlServer.Types.14.0.1016.290\lib\net40\Microsoft.SqlServer.Types.dll - + + + 3.5 @@ -76,93 +71,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -187,9 +95,6 @@ PreserveNewest - - - False @@ -217,19 +122,6 @@ Always - - - - This project references NuGet package(s) that are missing on this computer. %0AUse NuGet Package Restore to download them. %0AFor more information, see http://go.microsoft.com/fwlink/?LinkID=322105. %0AThe missing file is {0}. - - - - - if exist "$(ProjectDir)obj" rd "$(ProjectDir)obj" /S /Q -powershell.exe -ExecutionPolicy Unrestricted [io.file]::WriteAllText('$(TargetDir)SQL Scripts\Register.sql', ((gc '$(TargetDir)SQL Scripts\Register.sql') -replace 'DLLPath', '$(TargetPath)' -join \"`r`n\")) -powershell.exe -ExecutionPolicy Unrestricted [io.file]::WriteAllText('$(TargetDir)SQL Scripts\RegisterAndValidate.sql', ((gc '$(TargetDir)SQL Scripts\RegisterAndValidate.sql') -replace 'ScriptDirPath', '$(TargetDir)SQL Scripts' -join \"`r`n\")) -exit 0 - - \ No newline at end of file +