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

proj.db file is missing which is required to create coordinate transformation. #7

Open
sravanporipireddy opened this issue Jul 30, 2024 · 4 comments

Comments

@sravanporipireddy
Copy link

sravanporipireddy commented Jul 30, 2024

const char* pszProjection = GDALGetProjectionRef(dataset);
    if (pszProjection != NULL) {
        printf("[GDAL]Projection ref is: %s\n", pszProjection);
    } else {
        printf("[GDAL]Projection reference is NULL.\n");
    }
    //Create spatial reference from WKT
    OGRSpatialReferenceH datasetSRS = OSRNewSpatialReference(pszProjection);
    if (datasetSRS == NULL) {
        NSLog(@"[GDAL]Failed to create spatial reference from WKT");
        GDALClose(dataset);
        return nil;
    }
In the above scenario to create spatial reference for a given gdal dataset using projection reference, we need proj.db file which usually is generated while creating proj lib.

Can you make this generated proj.db file a part of this.
@Lumyk
Copy link
Member

Lumyk commented Jul 30, 2024

const char* pszProjection = GDALGetProjectionRef(dataset);
    if (pszProjection != NULL) {
        printf("[GDAL]Projection ref is: %s\n", pszProjection);
    } else {
        printf("[GDAL]Projection reference is NULL.\n");
    }
    //Create spatial reference from WKT
    OGRSpatialReferenceH datasetSRS = OSRNewSpatialReference(pszProjection);
    if (datasetSRS == NULL) {
        NSLog(@"[GDAL]Failed to create spatial reference from WKT");
        GDALClose(dataset);
        return nil;
    }
In the above scenario to create spatial reference for a given gdal dataset using projection reference, we need proj.db file which usually is generated while creating proj lib.

Can you make this generated proj.db file a part of this.

Hi, you could check build 1.0.1

@sravanporipireddy
Copy link
Author

sravanporipireddy commented Jul 30, 2024

Hey, I did check 1.0.1 but there is no proj.db file.

Using the following code we should be able to achieve that provided we have proj.db in the app bundle.

if let projDbPath = Bundle.main.path(forResource: "proj", ofType: "db") {
            let projLibPath = (projDbPath as NSString).deletingLastPathComponent
            setenv("PROJ_LIB", projLibPath, 1)
            OrcaLog.info?.message("[Map2D] PROJ_LIB env set to: \(projLibPath)")
        } else {
            OrcaLog.error?.message("[Map2D] proj.db not found in the app bundle.")
        }

@Lumyk
Copy link
Member

Lumyk commented Jul 30, 2024

Hey, I did check 1.0.1 but there is no proj.db file.

Using the following code we should be able to achieve that provided we have proj.db in the app bundle.

if let projDbPath = Bundle.main.path(forResource: "proj", ofType: "db") {
            let projLibPath = (projDbPath as NSString).deletingLastPathComponent
            setenv("PROJ_LIB", projLibPath, 1)
            OrcaLog.info?.message("[Map2D] PROJ_LIB env set to: \(projLibPath)")
        } else {
            OrcaLog.error?.message("[Map2D] proj.db not found in the app bundle.")
        }

proj.db can’t be in the main bundle. You can find it in gdal.xcframework added in the headers folder. Here you can find the latest compiled file. This framework is installed as a dependency for this library. So, if you need exactly proj.db, you can find it in the framework bundle. Maybe I missed some idea, anyway, you are welcome to PR ;)

@sravanporipireddy
Copy link
Author

sravanporipireddy commented Jul 30, 2024

Unfortunately i am not able to build this on my machine.
You can copy proj.db to your project and update the package.swift file with resources this way we can make this file a part of bundle and access it.

    ```

.target(
name: "gdal-swift",
dependencies: ["gdal"],
resources: [
.process("proj.db")]
path: "Sources",
exclude: ["gdal"],
cSettings: [.define("VALID_ARCHS", to: "arm64")],
cxxSettings: [.define("VALID_ARCHS", to: "arm64")],
linkerSettings: [
.linkedLibrary("sqlite3"),
.linkedLibrary("z"),
.linkedLibrary("xml2"),
.linkedLibrary("iconv")
]
)


You can follow the link below if you need further clarification
[https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package] 

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

No branches or pull requests

2 participants