code: public String getQueryString(TableSchema tableSchema, Phase phase) throws Exception {
  		StringWriter sw = new StringWriter();
  		PrintWriter pw = new PrintWriter(sw);
  		
  		if( Type.X == type ) {
  			pw.print("ST_X");
  		} else if( Type.Y == type ) {
  			pw.print("ST_Y");
  		} else {
  			throw new Exception("Can not handle type: "+type);
  		}
  
  		pw.print("(ST_Centroid(coalesce(ST_GeometryN(");
  		pw.print(fieldName);
  		pw.print(",1),");
  		pw.print(fieldName);
  		pw.print(")))");
  
  		if( Phase.SELECT == phase ) {
  			if( Type.X == type ) {
  				pw.print(" AS x");
  			} else if( Type.Y == type ) {
  				pw.print(" AS y");
  			} else {
  				throw new Exception("Can not handle type: "+type);
  			}
  		}
  
  		pw.flush();
  		return sw.toString();
  	}
docs: /*
  ST_X(ST_Centroid(coalesce(ST_GeometryN(the_geom,1),the_geom)))
  ST_Y(ST_Centroid(coalesce(ST_GeometryN(the_geom,1),the_geom)))
  
  ST_GeometryN - Return the 1-based Nth geometry if the geometry is a
  GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or
  MULTIPOLYGON. Otherwise, return NULL.
  ST_Centroid  - Returns the geometric center of a geometry
  coalesce     - The COALESCE function returns the first of its arguments that
  is not null. Null is returned only if all arguments are null.
  
  ST_X(
  ST_Centroid(
  coalesce(
  ST_GeometryN(
  the_geom
  ,1
  )
  ,the_geom
  )
  )
  )