code: 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;
      }
docs: Serializes all points of the input into a list of their coordinates
  
  @param input a geometry whose points are to be converted to a list of coordinates
  @return an array containing arrays with x,y and optionally z and m values.