25             List<Coordinate> newcoords=
new ArrayList<Coordinate>();
 
   26             if(ords.equalsIgnoreCase(
"xy")) {
 
   27                 for(Coordinate coord:geom.getCoordinates()) {
 
   28                         if(coord instanceof CoordinateXYM) {
 
   29                                 newcoords.add(
new CoordinateXYM(coord.getY(),coord.getX(),coord.getM()));
 
   30                         }
else if(coord instanceof CoordinateXYZM) {
 
   31                                 newcoords.add(
new CoordinateXYZM(coord.getY(),coord.getX(),coord.getZ(),coord.getM()));
 
   33                                 newcoords.add(
new Coordinate(coord.getY(),coord.getX()));                               
 
   36             }
else if(ords.equalsIgnoreCase(
"xz")) {
 
   37                 for(Coordinate coord:geom.getCoordinates()) {
 
   38                         if(coord instanceof CoordinateXYM) {
 
   39                                 throw new RuntimeException(
"Coordinates do not contain a Z value");
 
   40                         }
else if(coord instanceof CoordinateXYZM) {
 
   41                                 newcoords.add(
new CoordinateXYZM(coord.getZ(),coord.getY(),coord.getX(),coord.getM()));
 
   43                                 newcoords.add(
new Coordinate(coord.getZ(),coord.getY(),coord.getX()));                                  
 
   46             }
else if(ords.equalsIgnoreCase(
"yz")) {
 
   47                 for(Coordinate coord:geom.getCoordinates()) {
 
   48                         if(coord instanceof CoordinateXYM) {
 
   49                                 throw new RuntimeException(
"Coordinates do not contain a Z value");
 
   50                         }
else if(coord instanceof CoordinateXYZM) {
 
   51                                 newcoords.add(
new CoordinateXYZM(coord.getX(),coord.getZ(),coord.getY(),coord.getM()));
 
   53                                 newcoords.add(
new Coordinate(coord.getX(),coord.getZ(),coord.getY()));                          
 
   56             }
else if(ords.equalsIgnoreCase(
"xm")) {
 
   57                 for(Coordinate coord:geom.getCoordinates()) {
 
   58                         if(coord instanceof CoordinateXYM) {
 
   59                                 newcoords.add(
new CoordinateXYM(coord.getM(),coord.getY(),coord.getX()));
 
   60                         }
else if(coord instanceof CoordinateXYZM) {
 
   61                                 newcoords.add(
new CoordinateXYZM(coord.getM(),coord.getY(),coord.getZ(),coord.getX()));
 
   63                                 throw new RuntimeException(
"Coordinates do not contain a M value");                             
 
   66             }
else if(ords.equalsIgnoreCase(
"ym")) {
 
   67                 for(Coordinate coord:geom.getCoordinates()) {
 
   68                         if(coord instanceof CoordinateXYM) {
 
   69                                 newcoords.add(
new CoordinateXYM(coord.getX(),coord.getM(),coord.getY()));
 
   70                         }
else if(coord instanceof CoordinateXYZM) {
 
   71                                 newcoords.add(
new CoordinateXYZM(coord.getX(),coord.getM(),coord.getZ(),coord.getY()));
 
   73                                 throw new RuntimeException(
"Coordinates do not contain a M value");                             
 
   76             }
else if(ords.equalsIgnoreCase(
"zm")) {
 
   77                 for(Coordinate coord:geom.getCoordinates()) {
 
   78                         if(coord instanceof CoordinateXYM) {
 
   79                                 throw new RuntimeException(
"Coordinates do not contain a M and Z value");      
 
   80                         }
else if(coord instanceof CoordinateXYZM) {
 
   81                                 newcoords.add(
new CoordinateXYZM(coord.getX(),coord.getY(),coord.getM(),coord.getZ()));
 
   83                                 throw new RuntimeException(
"Coordinates do not contain a M and Z value");                               
 
   87                 throw new RuntimeException(
"Invalid second argument"); 
 
   89             return LiteralUtils.createGeometry(newcoords, geom.getGeometryType(), geom.getSRID());