Menu

Point, Line, PolyLine, Polygon

Developers
2021-05-10
2022-03-01
1 2 > >> (Page 1 of 2)
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-10

    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

     
    • Paul Higgins

      Paul Higgins - 2022-01-30

      Jan,

      Just read this how do I get those classes?

       
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-11

    First one need some support class

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-11

    and the point

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-11

    the class that use them, PolyShape

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-11

    and Polygon can handle combinations, though need some more work

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-11

    /**/

    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'

     
    👍
    1

    Last edit: Jan-Erik Lärka 2021-05-12
  • Rick McGuire

    Rick McGuire - 2021-05-19

    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)".

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2021-05-19

    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.

     
  • Paul Higgins

    Paul Higgins - 2022-01-30

    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
  • Paul Higgins

    Paul Higgins - 2022-01-31

    Jan,
    This is really good stuff. I think will solve some difficult problems in my program.

     
    • Lee Peedin

      Lee Peedin - 2022-01-31

      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

      On Jan 30, 2022, at 10:39 PM, Paul Higgins phiggins-99@users.sourceforge.net wrote:

      
      Jan,
      This is really good stuff. I think will solve some difficult problems in my program.

      Point, Line, PolyLine, Polygon

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/oorexx/discussion/408479/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2022-02-01

    something to try out

     
  • Paul Higgins

    Paul Higgins - 2022-02-01

    Thanks but I get the same error: with the new clss

    Again here is code:

    LS1 =  .PolyShape~new( '-82.351362,23.144393    -82.377884,23.158500 -82.400960,23.147176 -82.377254,23.146636  -82.366451,23.157573')  
    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
    

    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".

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2022-02-01

    Ahh,
    A limitation of the design... I'll have to look at that, great!

     

    Last edit: Jan-Erik Lärka 2022-02-01
  • Jan-Erik Lärka

    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.

     
  • Paul Higgins

    Paul Higgins - 2022-02-01

    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

     
  • Paul Higgins

    Paul Higgins - 2022-02-01

    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

     
  • Paul Higgins

    Paul Higgins - 2022-02-01

    Sorry here it is,,

     
  • Paul Higgins

    Paul Higgins - 2022-02-01

    Jan, any idea why I receive .Nil with that code?

     
  • Paul Higgins

    Paul Higgins - 2022-02-01

    If I just use simple coordinates rather than lat/lon it still returns.Nil

    poly = .Polygon~new( '5,3,0 5,7,0 8,7,0 8,3,0 5,3,0' )
    say 'poly='poly
    line = .PolyShape~new( '9,1 7,2 6,6',.false ) 
    say 'line='line
    say poly~intersectionPoint( line) -- returns .Nil
    
     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2022-02-02

    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.

     
  • Paul Higgins

    Paul Higgins - 2022-02-04

    Let me know if you want me to test anything new.

     
  • Jan-Erik Lärka

    Jan-Erik Lärka - 2022-02-04

    something to try out.

    /**/
    PARSE VERSION interpreter ver build
    SAY interpreter
    SAY ver
    SAY build
    
    bongo = .Polygon~new( '5,3,0 5,7,0 8,7,0 8,3,0 5,3,0' )
    
    say bongo~contains( .Point~new( 6,6 ) ) --1
    say bongo~contains( .PolyShape~new( '6,6 7,4' ) ) --1
    say bongo~contains( .PolyShape~new( '6,6 7,4 9,4' ) ) --0
    say bongo~intersect( .PolyShape~new( '6,6 7,4 8,4' ) ) --3.2
    say 'Intersect at:' bongo~intersectionpoint( .PolyShape~new( '6,6 7,4 8,4' ) )~toString
    
    navi = .PolyShape~new( '1,0,0 3,3,0' )
    chk = .PolyShape~new
    chk~prepare( '1,1,0 5,4,0' )
    say 'Intersect at:' navi~intersectionpoint( chk )~toString
    
    pbox = bongo~box
    say pbox[ 1 ]~toString pbox[ 1 ]~x||','||pbox[ 2 ]~y||',0' pbox[2]~toString pbox[ 2 ]~x||','||pbox[ 1 ]~y||',0' pbox[ 1 ]~toString
    bbox = bongo~box( 3 )
    say bbox[ 1 ]~toString bbox[ 1 ]~x||','||bbox[ 2 ]~y||',0' bbox[2]~toString bbox[ 2 ]~x||','||bbox[ 1 ]~y||',0' bbox[ 1 ]~toString
    
    LS1 = .PolyShape~new( '-82.351362,23.144393 -82.377884,23.158500 -82.400960,23.147176 -82.377254,23.146636 -82.366451,23.157573' )
    LS2 = .PolyShape~new( '-82.369393,23.165881 -82.382508,23.160703 -82.381667,23.149727', .false )
    
    say 'LS1='LS1
    say 'LS2='LS2
    say ls1~toString(,,.true)
    say ls2~toString(,, 'Points')
    
    pt = LS1~intersectionPoint( LS2, 2 )
    say 'Sections that intersect' LS1~intersect( LS2 )
    if .Nil=pt then say 'PT is .nil'
    else say 'pt='pt~tostring(,, 'Points')
    
    ::REQUIRES 'Polygon.cls'
    ::REQUIRES 'Polyshape.cls'
    

    Gave me the output:

    OBJREXX
    6.05
    14 Sep 2021
    1
    1
    0
    3.2
    Intersect at: 8,4,0
    Intersect at: 2.33333333,2,0
    5,3,0 5,7,0 8,7,0 8,3,0 5,3,0
    2,0,0 2,10,0 11,10,0 11,0,0 2,0,0
    LS1=a Polygon
    LS2=a PolyLine
    -82.351,23.144,0 -82.378,23.159,0 -82.401,23.147,0 -82.377,
    23.147,0 -82.366,23.158,0 -82.351,23.144,0
    (-82.369,23.166,0), (-82.383,23.161,0), (-82.382,23.15,0)
    Sections that intersect 2.2
    pt=-82.3821778,23.1563924,0

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.