Opened 10 years ago
Closed 8 years ago
#2658 closed defect (fixed)
[PATCH] v.to.db compactness gives wrong results in feet location
Reported by: | annakrat | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.0.5 |
Component: | LibGIS | Version: | svn-releasebranch70 |
Keywords: | v.to.db, units, area, compactness | Cc: | |
CPU: | Unspecified | Platform: | All |
Description
I was looking in the source code of v.to.db to understand if computed area is in meters squared or location units (feet in my case). I realized area is converted to meters squared, however, perimeter seems to be in map units (feet). Therefore compactness is wrong when units are not meters (latlon is fine I guess). Setting feet as units doesn't influence compactness computation.
Currently the library functions for computing area and perimeter don't behave consistently.
Attachments (1)
Change History (12)
comment:1 by , 9 years ago
Summary: | v.to.db compactness gives wrong results in feet location → [PATCH] v.to.db compactness gives wrong results in feet location |
---|
by , 9 years ago
Attachment: | v_to_db_length_units.diff added |
---|
follow-up: 6 comment:5 by , 9 years ago
follow-up: 7 comment:6 by , 9 years ago
Replying to annakrat:
Replying to neteler:
Will you apply the patch?
I applied the patch, but needs more testing.
As mentioned, the patch has some side effects in terms of weird results in terms of decimals.
I agree that it is better than leaving as is, but in the long run, changing area calculations to always return current location units might a better idea.
This would entail changing G_area_of_polygon() and this will probably be quite invasive as any library function or module calling this function would have to be updated.
In the meantime this should be backported IMHO.
Moritz
comment:7 by , 9 years ago
Priority: | major → normal |
---|
Replying to mlennert:
Replying to annakrat:
Replying to neteler:
Will you apply the patch?
I applied the patch, but needs more testing.
As mentioned, the patch has some side effects in terms of weird results in terms of decimals.
I agree that it is better than leaving as is, but in the long run, changing area calculations to always return current location units might a better idea.
This would entail changing G_area_of_polygon() and this will probably be quite invasive as any library function or module calling this function would have to be updated.
In the meantime this should be backported IMHO.
Done in r67327.
comment:10 by , 9 years ago
Milestone: | 7.0.4 → 7.0.5 |
---|
comment:11 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to annakrat:
And perimeter information is wrong when using unit=feet parameter:
Then, when asking for perimeter without unit parameter, you get the correct perimeter in feet:
However, when you explicitly ask for feet, the result is wrong since v.to.db assumes that the perimeter is in meters and converts to feet:
Currently, v.to.db seems to assume that all length and area values are in meters by default and converts them to the requested unit. For now I suggest to respect that assumption, unless the user explicitly asks for another unit. I'll attach a patch which attempts to do this. Please test.
The only inconvenience is that when the user asks for the original units (e.g. feet) the values are approximate only. Example for a 5 feet line:
The other (probably cleaner) option would be to create a new function for area calculation that returns area in location units and modify v.to.db to always return location units. However this demands a bit more modification of v.to.db.
In any case, whatever we chose, this will probably break scripts that rely on the existing behavior of v.to.db (even though I consider that behavior as a clear bug).