code: public static int[] colRowFromCoordinate( Coordinate coordinate, GridGeometry2D gridGeometry, Point point ) {
          try {
              DirectPosition pos = new DirectPosition2D(coordinate.x, coordinate.y);
              GridCoordinates2D worldToGrid = gridGeometry.worldToGrid(pos);
              if (point != null) {
                  point.x = worldToGrid.x;
                  point.y = worldToGrid.y;
              }
              return new int[]{worldToGrid.x, worldToGrid.y};
          } catch (InvalidGridGeometryException e) {
              e.printStackTrace();
          } catch (TransformException e) {
              e.printStackTrace();
          }
  
          point.x = Integer.MAX_VALUE;
          point.y = Integer.MAX_VALUE;
          return null;
      }
docs: Utility method to get col and row of a coordinate from a {@link GridGeometry2D}.
  
  @param coordinate the coordinate to transform.
  @param gridGeometry the gridgeometry to use.
  @param point if not <code>null</code>, the row col values are put inside the supplied point's x and y.
  @return the array with [col, row] or <code>null</code> if something went wrong.