Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoAPI 1.7.5 is incompatible with latest ProjNet4GeoAPI #31

Closed
kjeremy opened this issue Jul 11, 2018 · 12 comments
Closed

GeoAPI 1.7.5 is incompatible with latest ProjNet4GeoAPI #31

kjeremy opened this issue Jul 11, 2018 · 12 comments
Assignees
Labels
Projects

Comments

@kjeremy
Copy link

kjeremy commented Jul 11, 2018

See NetTopologySuite/GeoAPI#50

@FObermaier
Copy link
Member

FObermaier commented Jul 16, 2018

@HarelM
Copy link

HarelM commented Aug 3, 2018

I have tried the above package and it seems to solve the issue.
Can you please release/pre-release it to the regular NuGet repository?
This currently prevents me from bumping up the versions for the other NTS packages.

@HarelM
Copy link

HarelM commented Aug 11, 2018

@FObermaier any chance to publish your package to NuGet as a pre-release?

@HarelM
Copy link

HarelM commented Aug 14, 2018

@airbreather any chance you could help out here? I'm guessing this only needs to be published to NuGet...? This is currently a blocker in terms of upgrading to the officially released NTS version with all of the .net core updates...

@airbreather airbreather self-assigned this Aug 15, 2018
@airbreather
Copy link
Member

airbreather commented Aug 15, 2018

Should be done now, here was my test:

ConsoleApp0.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NetTopologySuite.Core" Version="1.15.0" />
    <PackageReference Include="ProjNet4GeoAPI" Version="1.4.0" />
  </ItemGroup>

</Project>

Program.cs

using System;

using GeoAPI.CoordinateSystems;
using GeoAPI.Geometries;

using NetTopologySuite.Geometries;

using ProjNet.Converters.WellKnownText;
using ProjNet.CoordinateSystems.Transformations;

static class Program
{
    static void Main()
    {
        const string WorldMercatorWkt = @"PROJCS[""WGS 84 / World Mercator"",GEOGCS[""WGS 84"",DATUM[""WGS_1984"",SPHEROID[""WGS 84"",6378137,298.257223563,AUTHORITY[""EPSG"",""7030""]],AUTHORITY[""EPSG"",""6326""]],PRIMEM[""Greenwich"",0,AUTHORITY[""EPSG"",""8901""]],UNIT[""degree"",0.0174532925199433,AUTHORITY[""EPSG"",""9122""]],AUTHORITY[""EPSG"",""4326""]],PROJECTION[""Mercator_1SP""],PARAMETER[""central_meridian"",0],PARAMETER[""scale_factor"",1],PARAMETER[""latitude_of_origin"",0],PARAMETER[""false_easting"",0],PARAMETER[""false_northing"",0],UNIT[""metre"",1,AUTHORITY[""EPSG"",""9001""]],AXIS[""Easting"",EAST],AXIS[""Northing"",NORTH],AUTHORITY[""EPSG"",""3395""]]";

        var worldMercator = (IProjectedCoordinateSystem)CoordinateSystemWktReader.Parse(WorldMercatorWkt, System.Text.Encoding.UTF8);
        var wgs84 = worldMercator.GeographicCoordinateSystem;

        var transformFactory = new CoordinateTransformationFactory();
        var wgs84ToWorldMercator = transformFactory.CreateFromCoordinateSystems(sourceCS: wgs84, targetCS: worldMercator).MathTransform;

        var hollywoodSignWgs84 = new Coordinate(-118.3215, 34.1341);
        var hollywoodSignWorldMercator = GeometryFactory.Default.CreatePoint(wgs84ToWorldMercator.Transform(hollywoodSignWgs84));

        var laxWgs84 = new Coordinate(-118.4085, 33.9416);
        var laxWorldMercator = GeometryFactory.Default.CreatePoint(wgs84ToWorldMercator.Transform(laxWgs84));

        Console.WriteLine("Distance from LAX to the Hollywood sign: " + hollywoodSignWorldMercator.Distance(laxWorldMercator) + " meters");
    }
}

Output

Distance from LAX to the Hollywood sign: 27502.1310701851 meters

@osmvermesser
Copy link

hi!

i add to this - because i did not find an other way of help.

i even update to 1.7.5 in vb.net and my old code looks like

Dim csFact As CoordinateSystemFactory = New CoordinateSystemFactory()
Dim ctFact As CoordinateTransformationFactory = New CoordinateTransformationFactory()

    Dim gcs_WGS84 As ProjNet.CoordinateSystems.GeographicCoordinateSystem = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84

    Dim EPSG31468 As ICoordinateSystem = csFact.CreateFromWkt("PROJCS[""DHDN / 3-degree Gauss-Kruger zone 4 (E-N)"",GEOGCS[""DHDN"",DATUM[""Deutsches_Hauptdreiecksnetz"",SPHEROID[""Bessel 1841"",6377397.155,299.1528128,AUTHORITY[""EPSG"",""7004""]],TOWGS84[598.1,73.7,418.2,0.202,0.045,-2.455,6.7],AUTHORITY[""EPSG"",""6314""]],PRIMEM[""Greenwich"",0,AUTHORITY[""EPSG"",""8901""]],UNIT[""degree"",0.0174532925199433,AUTHORITY[""EPSG"",""9122""]],AUTHORITY[""EPSG"",""4314""]],PROJECTION[""Transverse_Mercator""],PARAMETER[""latitude_of_origin"",0],PARAMETER[""central_meridian"",12],PARAMETER[""scale_factor"",1],PARAMETER[""false_easting"",4500000],PARAMETER[""false_northing"",0],UNIT[""metre"",1,AUTHORITY[""EPSG"",""9001""]],AXIS[""Easting"",EAST],AXIS[""Northing"",NORTH],AUTHORITY[""EPSG"",""5678""]]")
    Dim utm32 As IProjectedCoordinateSystem = ProjectedCoordinateSystem.WGS84_UTM(32, True)
    Dim trans As ICoordinateTransformation = ctFact.CreateFromCoordinateSystems(EPSG31468, gcs_WGS84)

NewCoordinate = trans.MathTransform.Transform(OldCoordinate)

is there somebody who could help? the code example of airbreather i am not able to migrate to my project.

regards Jan

@FObermaier
Copy link
Member

The information provided is incomplete.

  • what kind of build failure message do you see?
  • can you set up a sample that you can show?

@osmvermesser
Copy link

Hi!

i did not understand every think but here is the message of the vs

2021-04-30_07h41_53

Hallo Felix,
vom Namen her vermute ich, dass Du aus dem deutschsprachigen Raum kommst. Leider verstehe ich Deine Rückfrage nicht so ganz.

Die Fehlermeldung aus VS habe ich oben einmal eingefügt.

Ein Beispiel? Die betreffenden Codezeilen habe ich ja auch schon vor Deiner Rückmeldung schon gepostet. Oder meinst Du etwas anderes?

Regards / Gruß Jan

@FObermaier
Copy link
Member

@osmvermesser, while you are right about me living in germany, we don't want to exclude others.

Looking at the documentation for BC31091 reveals that there must be some mismatch. Can you post the packages that you reference in your project, or the content of the project file?

@osmvermesser
Copy link

@FObermaier , I don't want to exclude anyone and if I had understood what it was about I would have continued to write in English!

i attach my vb-file

niv2osmand.txt

the references:

2021-04-30_11h07_30

2021-04-30_11h08_03

I hope this are the required informations.?!??

regards Jan

@HarelM
Copy link

HarelM commented Apr 30, 2021

@FObermaier
Copy link
Member

FObermaier commented Apr 30, 2021

ProjNet v1.3.0.4 does not work with GeoAPI v1.7.5, you should use v1.7.3
ProjNet v1.4.1 works with GeoAPI v1.7.5
If you don't have any constraints that require GeoAPI I encourage you to use the ProjNet v2.0 package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
ProjNet V2
  
Done
Development

No branches or pull requests

5 participants