📄 pehorizonlookup.java
字号:
/**
*
*/
package com.esri.solutions.jitk.web.projection.horizon;
import com.esri.adf.web.data.geometry.WebExtent;
import com.esri.adf.web.data.geometry.WebSpatialReference;
import com.esri.sde.sdk.pe.PeCoordinateSystem;
import com.esri.sde.sdk.pe.PeGeographicCS;
import com.esri.sde.sdk.pe.PeHorizon;
import com.esri.sde.sdk.pe.PeProjectedCS;
import com.esri.sde.sdk.pe.PeProjectionException;
/**
* @author vlad2928
*
*/
public class PEHorizonLookup implements IHorizonLookup {
/* (non-Javadoc)
* @see com.esri.solutions.jitk.web.projection.horizon.IHorizonLookup#lookup(int)
*/
//A pcs horizon usually has many many points....KPC
public WebExtent lookup(int id) {
WebExtent horizon = null;
WebSpatialReference wsr = WebSpatialReference.getWebSpatialReference(id);
if(wsr != null) {
try {
PeCoordinateSystem cs = PeCoordinateSystem.fromString(wsr.getDefinitionString());
if(cs != null) {
if(cs instanceof PeProjectedCS) {
PeHorizon[] peHorizon = ((PeProjectedCS)cs).horizonPcsGenerate();
if(peHorizon != null && peHorizon.length > 0) {
double[] coords = peHorizon[0].getCoord();
double xmin = coords[0];
double xmax = xmin;
double ymin = coords[1];
double ymax = ymin;
int cnt = 2;
while (cnt < coords.length){
if (coords[cnt]>xmax)
xmax = coords[cnt];
else if (coords[cnt]<xmin)
xmin = coords[cnt];
cnt++;
if (coords[cnt]>ymax)
ymax = coords[cnt];
else if (coords[cnt]<ymin)
ymin = coords[cnt];
cnt++;
}
horizon = new WebExtent(xmin, ymin, xmax, ymax, wsr);
peHorizon[0].delete();
}
} else if(cs instanceof PeGeographicCS) {
//PeGeographicCS gcs = (PeGeographicCS) cs;
horizon = new WebExtent(-180, -90, 180, 90, wsr);
}
}
} catch(PeProjectionException ex) {}
}
return horizon;
}
/*
public WebExtent lookup(int id) {
WebExtent horizon = null;
WebSpatialReference wsr = WebSpatialReference.getWebSpatialReference(id);
if(wsr != null) {
try {
PeCoordinateSystem cs = PeCoordinateSystem.fromString(wsr.getDefinitionString());
if(cs != null) {
if(cs instanceof PeProjectedCS) {
PeHorizon[] peHorizon = ((PeProjectedCS)cs).horizonPcsGenerate();
if(peHorizon != null && peHorizon.length > 0) {
double[] coords = peHorizon[0].getCoord();
horizon = new WebExtent(coords[0], coords[1], coords[2], coords[3], wsr);
}
} else if(cs instanceof PeGeographicCS) {
//PeGeographicCS gcs = (PeGeographicCS) cs;
horizon = new WebExtent(-180, -90, 180, 90, wsr);
}
}
} catch(PeProjectionException ex) {}
}
return horizon;
}
*/
public static void main(String[] sparams) {
//System.out.println(new PEHorizonLookup().lookup(32601));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -