Re-opening PR for adding coordinate system retrieval for DWG files using ODA
What does this PR do?
Takes the work started in #11694 and adds a geolocated test file and stubs out a test
(copied from original PR) Get Coordinate System WKT representation from ODA capabilities when GDAL is build with ODA. Uses the existing system of SpatialReference from gdal.
What are related issues/pull requests?
#11694 , #11672
Tasklist
- [ ] AI (Copilot or something similar) supported my development of this PR
- [ ] Make sure code is correctly formatted (cf pre-commit configuration)
- [x] Add test case(s)
- I opened this PR to help out by adding a test case - though I'm a little ignorant of how to best configure this test, and as a result, I only have a partial test implementation in here that I would love some direction on how to finish.
- [ ] Add documentation
- [ ] Updated Python API documentation (swig/include/python/docs/)
- [ ] Review
- [ ] Adjust for comments
- [ ] All CI builds and checks have passed
Environment
Provide environment details, if relevant:
- OS: Ubuntu 23.04
- Compiler: gcc 12.3
- ODA version: 26.3 (Kernel and Drawing SDK's)
@planted-sam I've force pushed into your branch, rebasing on top of latest master, and adding a couple of fixes/adjustments. However I don't have the geo/spatial extension of the SDK available, so can you test that it still works after my changes ? Can you paste the output of "ogrinfo autotest/ogr/data/cad/geolocated_ac2018_IL83-EF.dwg -al" ?
@planted-sam I've force pushed into your branch, rebasing on top of latest master, and adding a couple of fixes/adjustments. However I don't have the geo/spatial extension of the SDK available, so can you test that it still works after my changes ? Can you paste the output of "ogrinfo autotest/ogr/data/cad/geolocated_ac2018_IL83-EF.dwg -al" ?
TY for helping pull this across! Here's the output of that command for the test DWG:
INFO: Open of `autotest/ogr/data/cad/geolocated_ac2018_IL83-EF.dwg'
using driver `DWG' successful.
Layer name: entities
Geometry: Unknown (any)
Feature Count: 1
Extent: (53.934828, -9.042338) - (54.064729, -8.951407)
Layer SRS WKT:
PROJCRS["IL83-EF",
BASEGEOGCRS["LL83",
DATUM["NAD83",
ELLIPSOID["GRS1980",6378137,298.2572221,
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["Degree",0.0174532925199433]]],
CONVERSION["unnamed",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",36.6666666666667,
ANGLEUNIT["Degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",-88.3333333333333,
ANGLEUNIT["Degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",0.999975,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",984250,
LENGTHUNIT["Foot_US",0.304800609601219],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["Foot_US",0.304800609601219],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["Foot_US",0.304800609601219]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["Foot_US",0.304800609601219]]]
Data axis to CRS axis mapping: 1,2
Layer: String (0.0)
SubClasses: String (0.0)
ExtendedEntity: String (0.0)
Linetype: String (0.0)
EntityHandle: String (0.0)
Text: String (0.0)
OGRFeature(entities):0
Layer (String) = 0
SubClasses (String) = AcDbEntity:AcDbCurve:AcDbPolyline
ExtendedEntity (String) =
Linetype (String) = 0
EntityHandle (String) = AF
Style = PEN(c:#bababa)
LINESTRING (53.9348275552477 -8.95140719009496,54.0647289966913 -8.95140719009496,54.0647289966913 -9.04233819910548,53.9348275552477 -9.04233819910548,53.9348275552477 -8.95140719009496)
Here's the output of that command for the test DWG:
the CRS is fine, but the geometry coordinates aren't consistent with a projected CRS. Is the file correctly geolocated in AutoCAD ? If so, we are missing something then
Here's the output of that command for the test DWG:
the CRS is fine, but the geometry coordinates aren't consistent with a projected CRS. Is the file correctly geolocated in AutoCAD ? If so, we are missing something then
Ah i had drawn a random rectangle then geolocated it afterwards, that probably made the coords themselves a little wack. Let me update this with a better file - will ping when I have that, sorry about this!
Changes unknown when pulling e9d2ba3829219c1586c11df721c218fd944ce86a on planted-sam:add-test-dwg-with-crs into ** on OSGeo:master**.
@rouault Made a new test DWG file, this time geolocating the new AutoCAD drawing, * then * drawing the single shape and saving the drawing. Here's the output from that same ogrinfo command:
INFO: Open of `autotest/ogr/data/cad/geolocated_rectangle_colorado_state_plane.dwg'
using driver `DWG' successful.
Layer name: entities
Geometry: Unknown (any)
Feature Count: 1
Extent: (-10.655831, -7.254153) - (10.921028, 7.719479)
Layer SRS WKT:
BOUNDCRS[
SOURCECRS[
PROJCRS["HARN/CO.CO-NF",
BASEGEOGCRS["HARN/CO.LL",
DATUM["HARN/CO",
ELLIPSOID["GRS1980",6378137,298.2572221,
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["Degree",0.0174532925199433]]],
CONVERSION["unnamed",
METHOD["Lambert Conic Conformal (2SP)",
ID["EPSG",9802]],
PARAMETER["Easting at false origin",3000000,
LENGTHUNIT["Foot_US",0.304800609601219],
ID["EPSG",8826]],
PARAMETER["Northing at false origin",1000000,
LENGTHUNIT["Foot_US",0.304800609601219],
ID["EPSG",8827]],
PARAMETER["Longitude of false origin",-105.5,
ANGLEUNIT["Degree",0.0174532925199433],
ID["EPSG",8822]],
PARAMETER["Latitude of false origin",39.3333333333333,
ANGLEUNIT["Degree",0.0174532925199433],
ID["EPSG",8821]],
PARAMETER["Latitude of 1st standard parallel",40.7833333333333,
ANGLEUNIT["Degree",0.0174532925199433],
ID["EPSG",8823]],
PARAMETER["Latitude of 2nd standard parallel",39.7166666666667,
ANGLEUNIT["Degree",0.0174532925199433],
ID["EPSG",8824]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["Foot_US",0.304800609601219]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["Foot_US",0.304800609601219]]]],
TARGETCRS[
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]],
ABRIDGEDTRANSFORMATION["Transformation from HARN/CO.LL to WGS84",
METHOD["Position Vector transformation (geog2D domain)",
ID["EPSG",9606]],
PARAMETER["X-axis translation",0,
ID["EPSG",8605]],
PARAMETER["Y-axis translation",0,
ID["EPSG",8606]],
PARAMETER["Z-axis translation",0,
ID["EPSG",8607]],
PARAMETER["X-axis rotation",0,
ID["EPSG",8608]],
PARAMETER["Y-axis rotation",0,
ID["EPSG",8609]],
PARAMETER["Z-axis rotation",0,
ID["EPSG",8610]],
PARAMETER["Scale difference",1,
ID["EPSG",8611]]]]
Data axis to CRS axis mapping: 1,2
Layer: String (0.0)
SubClasses: String (0.0)
ExtendedEntity: String (0.0)
Linetype: String (0.0)
EntityHandle: String (0.0)
Text: String (0.0)
OGRFeature(entities):0
Layer (String) = 0
SubClasses (String) = AcDbEntity:AcDbCurve:AcDbPolyline
ExtendedEntity (String) =
Linetype (String) = 0
EntityHandle (String) = 8C4B
Style = PEN(c:#000000)
LINESTRING (-10.6558306694897 7.71947864885078,10.9210281641317 7.71947864885078,10.9210281641317 -7.25415279106892,-10.6558306694897 -7.25415279106892,-10.6558306694897 7.71947864885078)
Is that more in line with what you'd expect to see? TBH I am very confused by how AutoCAD sets up it's coordinate systems lol
Is that more in line with what you'd expect to see? TBH I am very confused by how AutoCAD sets up it's coordinate systems lol
not really, coordinates should be somewhat close to Easting at false origin=300000 for X and Northing at false origin=1000000 for Y assuming the line is not too far away from the center of the projection.
Is that more in line with what you'd expect to see? TBH I am very confused by how AutoCAD sets up it's coordinate systems lol
not really, coordinates should be somewhat close to Easting at false origin=300000 for X and Northing at false origin=1000000 for Y assuming the line is not too far away from the center of the projection.
Isn't the whole point of the false origin to avoid needing to do that? Like the way I'm interpreting this is that you'd take the points in the Linestring and treat them all as an offset on top of that false origin point?
Isn't the whole point of the false origin to avoid needing to do that?
no. The point of the false easting/northing is to have positive coordinates in the area of interest of the projection. Your linestring with its current coordinates would be located arnd 36d7'6.033"N 115d39'13.091"W , so ~ 10 degrees at the west of the center of the projection and ~ 3 degrees south, which is very unlikely to be correct
The GDAL project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 28 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
-
that all unit tests are passing
-
that all comments by reviewers have been addressed
-
that there is enough information for reviewers, in particular link to any issues which this pull request fixes
-
that you have written unit tests where possible In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request. If there is no further activity on this pull request, it will be closed in 2 weeks.
While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 6 weeks. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the GDAL project can do to help push this PR forward please let us know how we can assist.