private double [ ] [ ] getPoints ( Geometry input ) { double [ ] [ ] result = new double [ input . getNumPoints ( ) ] [ ] ; for ( int i = 0 ; i < input . getPoints ( ) . size ( ) ; i ++ ) { Point p = input . getPointN ( i ) ; if ( p . isMeasured ( ) && p . is3D ( ) ) { result [ i ] = new double [ ] { p . getX ( ) , p . getY ( ) , p . getZ ( ) , p . getM ( ) } ; } else if ( p . isMeasured ( ) ) { // ideally we'd use something like Double.Nan, but JSON doesn't support that. result [ i ] = new double [ ] { p . getX ( ) , p . getY ( ) , 0 , p . getM ( ) } ; } else if ( p . is3D ( ) ) { result [ i ] = new double [ ] { p . getX ( ) , p . getY ( ) , p . getZ ( ) } ; } else { result [ i ] = new double [ ] { p . getX ( ) , p . getY ( ) } ; } } return result ; }
Serializes all points of the input into a list of their coordinates