grass icon indicating copy to clipboard operation
grass copied to clipboard

v.to.db: add JSON support

Open kritibirda opened this issue 1 year ago • 8 comments

Add JSON output support to v.to.db module. The output looks like as follows:

{
    "totals": {
        "area": 2219442027.2203522
    },
    "records": [
        {
            "category": 1,
            "area": 24375323.127803534
        },
        {
            "category": 2,
            "area": 2938964.3204806102
        },
        {
            "category": 3,
            "area": 50536154.294107705
        }
    ],
...
}

kritibirda avatar Jul 11 '24 19:07 kritibirda

@cwhite911 Hi! Can you please review this PR? I would like to use the JSON format added here in the v.report module's JSON implementation to keep the implementation simple.

kritibirda avatar Jul 25 '24 19:07 kritibirda

@cwhite911 Hi! Can you please review this PR? I would like to use the JSON format added here in the v.report module's JSON implementation to keep the implementation simple.

@kritibirda26 the schema looks good to me, however I'm debating if we should add the measurement unit to the root object.

cwhite911 avatar Jul 27 '24 15:07 cwhite911

If it's documented for now, it won't be breaking to add it at a later time if needed. So if you can't decide after thinking about it for a while, there's a way to keep the PR going.

echoix avatar Jul 27 '24 15:07 echoix

@cwhite911 can you please take another look at this PR?

kritibirda avatar Aug 01 '24 07:08 kritibirda

@kritibirda26 Please add additional unit tests to capture the all of the response data types (point, line, polygon, 3d vectors, mixed with the options: cat, area, compact, fd, perimeter, length, count, coor, start, end, sides, query, slope, sinuous, azimuth, bbox.

Let's also add the measurement unit to the root json object.

cwhite911 avatar Aug 01 '24 19:08 cwhite911

@cwhite911 Should there be at least one test covering each type and each option? asking because it doesn't seem possible to provide multiple options or types to v.to.db at once.

kritibirda avatar Aug 02 '24 05:08 kritibirda

@cwhite911 Should there be at least one test covering each type and each option? asking because it doesn't seem possible to provide multiple options or types to v.to.db at once.

Yes, we should add a test to make sure each key value pair is correctly generated for the option.

cwhite911 avatar Aug 13 '24 17:08 cwhite911

@cwhite911 I have added more tests and measurement units to the root of the object. Can you please suggest which maps/commands to use to test query, azimuth, sinuousity and slope?

kritibirda avatar Aug 20 '24 15:08 kritibirda

@cwhite911, Hi! I have updated the PR with tests for azimuth and sinuous. For slope, I tried to create a 3d map but failed. I also followed other examples of creating a 3d dataset from 2d (from the tests of other modules) but the slope always comes to be 0 in both plain and json mode.

kritibirda avatar Aug 29 '24 06:08 kritibirda

Missing to adjust cmakefiles to add json in v.to.db

echoix avatar May 15 '25 10:05 echoix