MetadataUtil { private static String buildWkt(CRSParameters parms) { StringBuilder builder = new StringBuilder(500); final String lineSep = System.getProperty("line.separator", "\n"); builder.append("PROJCS[") .append("\"") .append(parms.getMapprojn()) .append("\"") .append(",") .append(lineSep) .append("GEOGCS[") .append("\"") .append(parms.getGcs()) .append("\"") .append(",") .append(lineSep) .append("DATUM[") .append("\"") .append(parms.getHorizdn()) .append("\"") .append(",") .append(lineSep) .append("SPHEROID[") .append("\"") .append(parms.getEllips()) .append("\"") .append(",") .append(parms.getSemiaxis()) .append(",") .append(parms.getDenflat()) .append("]]") .append(",") .append(lineSep) .append("PRIMEM[") .append("\"") .append(parms.getPrimeM()) .append(",") .append(lineSep) .append("UNIT[") .append("\"") .append(parms.getUnit()) .append(",") .append(lineSep) .append("PROJECTION[") .append("\"") .append(parms.getProjection()) .append("\"]") .append(",") .append(lineSep) .append(getParameterNode("False_Easting",parms.getFeast())) .append(",") .append(lineSep) .append(getParameterNode("False_Northing",parms.getFnorth())) .append(",") .append(lineSep) .append(getParameterNode("Central_Meridian",parms.getLongcm())) .append(",") .append(lineSep) .append(getParameterNode("Standard_Parallel_1",29.5)) .append(",") .append(lineSep) .append(getParameterNode("Standard_Parallel_2",parms.getStdparll())) .append(",") .append(lineSep) .append(getParameterNode("Latitude_Of_Origin",parms.getLatprjo())) .append(",") .append(lineSep) .append("UNIT[") .append("\"") .append(parms.getLengthUnit()) .append("\"") .append(",") .append(parms.getLengthValue()) .append("]]"); return builder.toString(); }  static Document parseMetadataBody(String postBody); static ParsedMetadata parseMetadataXmlFile(String postBody); static String stripXMLProlog(String xml); static List<String> extractStringsFromCswDoc(Document cswDoc, String path); static String extractCollectionDateFromXml(Document xml, String attr); static Bbox getBoundingBoxFromFgdcMetadata(String inMetadata); static CoordinateReferenceSystem getCrsFromFgdcMetadata(String inMetadata); static List<Publication> getResourcesFromXml(Document doc, String path); static final String[] XML_PROLOG_PATTERNS; }
@Test public void testWktBuilder() throws FactoryException { String expString = getStringFromWKTBuilder(); CRSParameters parms = new CRSParameters(); parms.setDenflat(298.257222101); parms.setEllips("GRS 1980"); parms.setFeast(0.0); parms.setFnorth(0.0); parms.setGcs("GCS_North_American_1983"); parms.setHorizdn("North American Datum 1983"); parms.setLatprjo(23.0); parms.setLengthUnit("Meter"); parms.setLengthValue(1.0); parms.setLongcm(-96.0); parms.setMapprojn("Albers Conical Equal Area"); parms.setPrimeM("Greenwich\",0.0]"); parms.setProjection("Albers"); parms.setSemiaxis(6378137.0); parms.setStdparll(45.5); parms.setUnit("Degree\",0.0174532925199433]]"); String built = buildWkt(parms); System.out.println("String builtVia wkt parm dto: " + built); assertEquals(expString, built); }