I've written classes to handle general Point¹, Line², PolyLine² and Polygon²
Can read and produce WKT data as well.
Include support methods for Length, Offset, Contains, Translate etc.
Specialisations handle WGS84 (GPS) data, decode google strings, calculate (poly)line length in m, km and miles and KML xml-structure³.
Anyone interested?
¹) Separate class for Point
²) One class for Line, PolyLine and Polygon
³) Additional user data remain to add code for
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was just looking at the code here. One suggestion, you have a lot of places where you are checking the class of an argument using either DEFAULTNAME or OBJECTNAME. A better (and more reliable approach) would be to use "pnt~isA(.Point)".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are quite right... but does that also work in Object Rexx on OS/2?
Am currently writing it on OS/2 with that older interpreter as the developer of ooRexx 5.0 for OS/2 need some more time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are quite right... but does that also work in Object Rexx on OS/2?
Am currently writing it on OS/2 with that older interpreter as the
developer of ooRexx 5.0 for OS/2 need some more time.
Jan,
I downloaded our classes and the example you posted. But when I run it I get:
C:\SAT2CHART\SAT2CHART.Testing>Shape_test.rex
399 - ::method box
10 - ::REQUIRES 'Polygon.cls'
Error 99 running C:\SAT2CHART\SAT2CHART.Testing\Polygon.cls line 399: Translation error.
Error 99.902: Duplicate ::METHOD directive instruction.
and indeed there are two box methods in the Polygon.cls ??
I commented the 2nd box method and the example worked.
Last edit: Paul Higgins 2022-01-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wrote a similar library in the form of an ActiveX DLL many years ago, but it was pretty much rejected by the community due to it using OLE and only being available for Windows. Glad to see Jan has created this.
I changed the .PolyShape to .WGS84 and the result was .Nil changed back .PolyShape to try your modified ne .PolyShape and also go .Nil.
Here is the code with .PolyShape...
LS1 = .PolyShape~new( '-82.351362,23.144393 -82.377884,23.158500 -82.400960,23.147176 -82.377254,23.146636')
LS2 = .PolyShape~new( '-82.369393,23.165881 -82.382508,23.160703 -82.381667,23.149727',.false)
say 'LS1='LS1
say 'LS2='LS2
pt = LS1~intersectionPoint(LS2,2)
if .Nil=pt then say 'PT is .nil'
else say 'pt='pt
Here is the result:
LS1=a Polygon
LS2=a PolyLine
PT is .nil
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Jan, The sun is over the yard arm here in the Philippines and a bottle of whiskey is calling so I am crashing, The attachment is what those points look like. Goodnight
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
perhaps a bit late...
I've written classes to handle general Point¹, Line², PolyLine² and Polygon²
Can read and produce WKT data as well.
Include support methods for Length, Offset, Contains, Translate etc.
Specialisations handle WGS84 (GPS) data, decode google strings, calculate (poly)line length in m, km and miles and KML xml-structure³.
Anyone interested?
¹) Separate class for Point
²) One class for Line, PolyLine and Polygon
³) Additional user data remain to add code for
Jan,
Just read this how do I get those classes?
First one need some support class
and the point
the class that use them, PolyShape
and Polygon can handle combinations, though need some more work
/**/
poly = .Polygon~new( '5,3,0 5,7,0 8,7,0 8,3,0 5,3,0' )
say poly~contains( .Point~new( 6,6 ) ) --1 (.True)
say poly~contains( .PolyShape~new( '6,6 7,4' ) ) --1 (.True)
say poly~contains( .PolyShape~new( '6,6 7,4 9,4' ) ) --0 (.False)
say poly~intersect( .PolyShape~new( '6,6 7,4 8,4' ) ) --3.2 (The line segments that intersect!)
::REQUIRES 'Polygon.cls'
::REQUIRES 'Polyshape.cls'
Last edit: Jan-Erik Lärka 2021-05-12
I was just looking at the code here. One suggestion, you have a lot of places where you are checking the class of an argument using either DEFAULTNAME or OBJECTNAME. A better (and more reliable approach) would be to use "pnt~isA(.Point)".
You are quite right... but does that also work in Object Rexx on OS/2?
Am currently writing it on OS/2 with that older interpreter as the developer of ooRexx 5.0 for OS/2 need some more time.
Ah, no it wouldn't.
On Wed, May 19, 2021 at 4:50 PM "Jan-Erik Lärka" janeriklarka@users.sourceforge.net wrote:
Jan,
I downloaded our classes and the example you posted. But when I run it I get:
C:\SAT2CHART\SAT2CHART.Testing>Shape_test.rex
399 - ::method box
10 - ::REQUIRES 'Polygon.cls'
Error 99 running C:\SAT2CHART\SAT2CHART.Testing\Polygon.cls line 399: Translation error.
Error 99.902: Duplicate ::METHOD directive instruction.
and indeed there are two box methods in the Polygon.cls ??
I commented the 2nd box method and the example worked.
Last edit: Paul Higgins 2022-01-30
Jan,
This is really good stuff. I think will solve some difficult problems in my program.
I wrote a similar library in the form of an ActiveX DLL many years ago, but it was pretty much rejected by the community due to it using OLE and only being available for Windows. Glad to see Jan has created this.
Lee Peedin
something to try out
Thanks but I get the same error: with the new clss
Again here is code:
Result:
581 - Return .Point~new( self~point[ section + 1 ]~x - self~point[ section ]~x, self~point[ section + 1 ]~y - self~point[ section ]~y, self~point[ section + 1 ]~z - self~point[ section ]~z ) --dx, dy, dz
339 - d2 = shape~delta( j, j + 1 )
47 - pt = LS1~intersectionPoint(LS2,2)
Error 97 running C:\SAT2CHART\SAT2CHART.Testing\PolyShape.cls line 581: Object method not found.
Error 97.1: Object "The NIL object" does not understand message "X".
Ahh,
A limitation of the design... I'll have to look at that, great!
Last edit: Jan-Erik Lärka 2022-02-01
Added a "- 1" in the loop
Am busy (work) so could you please do check that it can detect the intersection point.
I changed the .PolyShape to .WGS84 and the result was .Nil changed back .PolyShape to try your modified ne .PolyShape and also go .Nil.
Here is the code with .PolyShape...
LS1 = .PolyShape~new( '-82.351362,23.144393 -82.377884,23.158500 -82.400960,23.147176 -82.377254,23.146636')
LS2 = .PolyShape~new( '-82.369393,23.165881 -82.382508,23.160703 -82.381667,23.149727',.false)
say 'LS1='LS1
say 'LS2='LS2
pt = LS1~intersectionPoint(LS2,2)
if .Nil=pt then say 'PT is .nil'
else say 'pt='pt
Here is the result:
LS1=a Polygon
LS2=a PolyLine
PT is .nil
Jan, The sun is over the yard arm here in the Philippines and a bottle of whiskey is calling so I am crashing, The attachment is what those points look like. Goodnight
Sorry here it is,,
Jan, any idea why I receive .Nil with that code?
If I just use simple coordinates rather than lat/lon it still returns.Nil
I'll have to adjust method delta, how to call it and some other parts of intersectionpoint.
delta only handle positive coordinates as it is.
Let me know if you want me to test anything new.
something to try out.
Gave me the output: