本文整理汇总了Java中org.opengis.referencing.crs.CoordinateReferenceSystem.toWKT方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateReferenceSystem.toWKT方法的具体用法?Java CoordinateReferenceSystem.toWKT怎么用?Java CoordinateReferenceSystem.toWKT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opengis.referencing.crs.CoordinateReferenceSystem
的用法示例。
在下文中一共展示了CoordinateReferenceSystem.toWKT方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSingleLineWKT
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* Turns the CRS into a single line WKT, more compatible with ESRI software
* @param crs
* @return
*/
String toSingleLineWKT(CoordinateReferenceSystem crs) {
String wkt = null;
try {
// this is a lenient transformation, works with polar stereographics too
Formattable formattable = (Formattable) crs;
wkt = formattable.toWKT(0, false);
} catch(ClassCastException e) {
wkt = crs.toWKT();
}
wkt = wkt.replaceAll("\n", "").replaceAll(" ", "");
return wkt;
}
示例2: toSingleLineWKT
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* Turns the CRS into a single line WKT
* The code within this method is a copy
* of {@link ShapefileDataStore#toSingleLineWKT(CoordinateReferenceSystem)}
*
* @param crs CoordinateReferenceSystem which should be formatted
* @return Single line String which can be written to PRJ file
*/
public static String toSingleLineWKT(CoordinateReferenceSystem crs) {
String wkt = null;
try {
// this is a lenient transformation, works with polar stereographics too
Formattable formattable = (Formattable) crs;
wkt = formattable.toWKT(0, false);
} catch(ClassCastException e) {
wkt = crs.toWKT();
}
wkt = wkt.replaceAll("\n", "").replaceAll(" ", "");
return wkt;
}
示例3: readTrack
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
static FeatureCollection<SimpleFeatureType, SimpleFeature> readTrack(Reader reader, GeoCoding geoCoding) throws IOException {
CsvReader csvReader = new CsvReader(reader, new char[]{'\t', ' '}, true, "#");
SimpleFeatureType trackFeatureType = createTrackFeatureType(geoCoding);
ListFeatureCollection featureCollection = new ListFeatureCollection(trackFeatureType);
double[] record;
int pointIndex = 0;
while ((record = csvReader.readDoubleRecord()) != null) {
if (record.length < 3) {
throw new IOException("Illegal track file format.\n" +
"Expecting tab-separated lines containing 3 values: lat, lon, data.");
}
float lat = (float) record[0];
float lon = (float) record[1];
double data = record[2];
final SimpleFeature feature = createFeature(trackFeatureType, geoCoding, pointIndex, lat, lon, data);
if (feature != null) {
featureCollection.add(feature);
}
pointIndex++;
}
if (featureCollection.isEmpty()) {
throw new IOException("No track point found or all of them are located outside the scene boundaries.");
}
final CoordinateReferenceSystem mapCRS = geoCoding.getMapCRS();
if (!mapCRS.equals(DefaultGeographicCRS.WGS84)) {
try {
transformFeatureCollection(featureCollection, mapCRS);
} catch (TransformException e) {
throw new IOException("Cannot transform the ship track onto CRS '" + mapCRS.toWKT() + "'.", e);
}
}
return featureCollection;
}
示例4: toWKT
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
public void toWKT() throws Exception {
// toWKT start
CoordinateReferenceSystem crs = CRS.decode("EPSG:32735");
String wkt = crs.toWKT();
System.out.println("wkt for EPSG:32735");
System.out.println( wkt );
// toWKT end
}
示例5: gotoCRS
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* Takes in a CRS, finds it in the list and highlights it
*
* @param crs
*/
@SuppressWarnings("unchecked")
public void gotoCRS(final CoordinateReferenceSystem crs) {
if (crs != null) {
final List list = codesList.getList();
final Set<Identifier> identifiers = new HashSet<Identifier>(crs.getIdentifiers());
final Set<Integer> candidates = new HashSet<Integer>();
for (int i = 0; i < list.getItemCount(); i++) {
for (final Identifier identifier : identifiers) {
final String item = list.getItem(i);
if (sameEPSG(crs, identifier, item) || exactMatch(crs, identifier, item)) {
codesList.setSelection(new StructuredSelection(item), false);
list.setTopIndex(i);
return;
}
if (isMatch(crs, identifier, item)) {
candidates.add(i);
}
}
}
if (candidates.isEmpty()) {
final java.util.List<String> input = (java.util.List<String>) codesList.getInput();
final String sourceCRSName = crs.getName().toString();
sourceCRS = crs;
input.add(0, sourceCRSName);
codesList.setInput(input);
codesList.setSelection(new StructuredSelection(sourceCRSName), false);
list.setTopIndex(0);
try {
final String toWKT = crs.toWKT();
wktText.setText(toWKT);
} catch (final RuntimeException e) {
ExceptionMonitor.show(wktText.getShell(), e, crs.toString() + " cannot be formatted as WKT"); //$NON-NLS-1$
wktText.setText("Unknown/Illegal WKT");
}
} else {
final Integer next = candidates.iterator().next();
codesList.setSelection(new StructuredSelection(list.getItem(next)), false);
list.setTopIndex(next);
}
}
}
示例6: process
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
@Execute
public void process() throws Exception {
if (pCode != null) {
CoordinateReferenceSystem crs = CrsUtilities.getCrsFromEpsg(pCode);
prjWkt = crs.toWKT();
}
if (filesList == null) {
filesList = new ArrayList<File>();
pathsList = new ArrayList<String>();
new FileTraversal(fileFilter){
public void onFile( final File f ) {
if (pRegex == null) {
filesList.add(f);
pathsList.add(f.getAbsolutePath());
} else {
if (f.getName().matches(".*" + pRegex + ".*")) { //$NON-NLS-1$//$NON-NLS-2$
filesList.add(f);
pathsList.add(f.getAbsolutePath());
}
}
}
}.traverse(new File(inFolder));
if (prjWkt != null) {
for( File file : filesList ) {
String nameWithoutExtention = FileUtilities.getNameWithoutExtention(file);
if (nameWithoutExtention != null) {
File prjFile = new File(file.getParentFile(), nameWithoutExtention + ".prj"); //$NON-NLS-1$
if (!prjFile.exists()) {
// create it
FileUtilities.writeFile(prjWkt, prjFile);
}
}
}
}
}
if (filesList.size() > fileIndex)
outCurrentfile = filesList.get(fileIndex).getAbsolutePath();
if (fileIndex == filesList.size() - 1) {
doProcess = false;
}
fileIndex++;
}
示例7: process
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
@Execute
public void process() throws Exception {
if (pCode != null) {
CoordinateReferenceSystem crs = CrsUtilities.getCrsFromEpsg(pCode, null);
prjWkt = crs.toWKT();
}
if (filesList == null) {
filesList = new ArrayList<File>();
pathsList = new ArrayList<String>();
new FileTraversal(fileFilter){
public void onFile( final File f ) {
if (pRegex == null) {
filesList.add(f);
pathsList.add(f.getAbsolutePath());
} else {
if (f.getName().matches(".*" + pRegex + ".*")) { //$NON-NLS-1$//$NON-NLS-2$
filesList.add(f);
pathsList.add(f.getAbsolutePath());
}
}
}
}.traverse(new File(inFolder));
if (prjWkt != null) {
for( File file : filesList ) {
String nameWithoutExtention = FileUtilities.getNameWithoutExtention(file);
if (nameWithoutExtention != null) {
File prjFile = new File(file.getParentFile(), nameWithoutExtention + ".prj"); //$NON-NLS-1$
if (!prjFile.exists()) {
// create it
FileUtilities.writeFile(prjWkt, prjFile);
}
}
}
}
}
if (filesList.size() > fileIndex)
outCurrentfile = filesList.get(fileIndex).getAbsolutePath();
if (fileIndex == filesList.size() - 1) {
doProcess = false;
}
fileIndex++;
}
示例8: getWKT
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
public String getWKT(String coordinateSystem) throws NoSuchAuthorityCodeException, FactoryException {
CoordinateReferenceSystem crs = CRS.decode(coordinateSystem);
String wkt = crs.toWKT();
return wkt;
}
开发者ID:MikeFot,项目名称:Java--GIS-Shapefile-Parser-and-Processor,代码行数:6,代码来源:CoordinateSystemsContainer.java