added a comment - - edited
I cooked up the attached patch (crs.patch), which tries to follow your indications about the extraction of the 2d component fo the CRS (ref. http://www.nabble.com/Re:-Getting-the-2d-equivalent-portion-of-a-3d-Crs-p15740034.html)
The extractions seems to work fine, thought I have a couple of issues:
* I'm not sure if the above way to build up the CR and CRS is the suggested one (and yes, I should move the list of known flat directions to a static variable)
* The resulting CRS seems good, but it does not equate to 4326, not even using CRS.equalsIgnoreMetadata. For this, try out the following snippet:
CoordinateReferenceSystem threeDim = CRS.decode("EPSG:4327");
CoordinateReferenceSystem flat = CRS.getHorizontalCRS(threeDim);
System.out.println("2D portion of 4327:\n" + flat);
System.out.println("4326:\n" + CRS.decode("EPSG:4326"));
System.out.println("Looking up EPSG code: " + CRS.lookupEpsgCode(flat, true));
System.out.println("2D portion of 4327 equals to 4326: "
+ CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), flat));
Having them equate would be the icing on the cake, but it's not necessary.
I would like to commit the patch if possible.