📄 mapperservlet.java
字号:
}
return true;
}
private void debugSession(HttpServletRequest req,
HttpSession session)
{
log("Request and Session Data:");
log("Session ID in Request: " + req.getRequestedSessionId());
log("Session ID in Request from Cookie: " +
req.isRequestedSessionIdFromCookie());
// If using Servlet API 2.0, you must use the isRequestedSessionIdFromUrl
// method. For later APIs, use isRequestedSessionIdFromURL instead.
log("Session ID in Request from URL: " +
req.isRequestedSessionIdFromURL());
log("Valid Session ID: " + req.isRequestedSessionIdValid());
log("Session Data:");
log("New Session: " + session.isNew());
log("Session ID: " + session.getId());
log("Creation Time: " + session.getCreationTime());
log("Last Accessed Time: " + session.getLastAccessedTime());
}
/*//////////////////////////////////////////////////////////////////////////////////////////////////
轨迹回放显示车辆
///////////////////////////////////////////////////////////////////////////////////////////////////*/
public boolean showResultTrace(MapJ mapj,double[][] m_PointArrary,String tel) {
String StrAnnLayerName = "AnnLayer";
Layer lyrAnn;
Attribute attrib[] = new Attribute[7];
attrib[0] = new Attribute(tel);
attrib[1] = new Attribute("china");
attrib[2] = new Attribute("beijng");
attrib[3] = new Attribute("bj");
attrib[4] = new Attribute("100000");
attrib[5] = new Attribute(116.196084);
attrib[6] = new Attribute(39.555990);
DoublePoint m_dPoint=new DoublePoint();
String columns[] = {"Name", "Address", "city", "State", "Zip", "x", "y"};
int types[] = { TableInfo.COLUMN_TYPE_STRING,
TableInfo.COLUMN_TYPE_STRING,
TableInfo.COLUMN_TYPE_STRING,
TableInfo.COLUMN_TYPE_STRING,
TableInfo.COLUMN_TYPE_STRING,
TableInfo.COLUMN_TYPE_DOUBLE,
TableInfo.COLUMN_TYPE_DOUBLE};
int typesTrace[] = { TableInfo.COLUMN_TYPE_STRING};
String columnsTrace[] ={"name"};
Attribute att[] = new Attribute[1];
att[0] = new Attribute("trace");
if (mapj.getLayers().getLayer(StrAnnLayerName)!=null) {
lyrAnn = mapj.getLayers().getLayer(StrAnnLayerName);
if (!lyrAnn.isAnnotationLayer()) return false;
try {
ArrayList columns_a = new ArrayList();
TableInfo tabInfo = lyrAnn.getTableInfo();
for (int i=0; i<tabInfo.getColumnCount();++i) {
columns_a.add(tabInfo.getColumnName(i));
}
RewindableFeatureSet rFtrSet = new RewindableFeatureSet(lyrAnn.searchAll(columns_a, null));
Feature ftr = rFtrSet.getNextFeature();
while (ftr != null) {
lyrAnn.removeFeature(ftr.getPrimaryKey());
ftr = rFtrSet.getNextFeature();
}
rFtrSet.dispose();
} catch (Exception ed) {
ed.printStackTrace();
return false;
}
}else {
try {
CoordSys curCoordSys = mapj.getNumericCoordSys();
int[] primarykey = new int[1];
TableInfoImpl tii = new TableInfoImpl(StrAnnLayerName, curCoordSys, columns, types,7,primarykey, false);
AnnotationTableDescHelper annTDHelper = new AnnotationTableDescHelper(StrAnnLayerName);
AnnotationDataProviderHelper annDPHelper = new AnnotationDataProviderHelper(tii);
LocalDataProviderRef localDPRef = new LocalDataProviderRef(annDPHelper);
lyrAnn = mapj.getLayers().insert(localDPRef, annTDHelper, 0, StrAnnLayerName);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/////Trace////////////////////////////////////////////////////////////////////////////////////////////////
Rendition rend = RenditionImpl.getDefaultRendition();
rend.setValue(Rendition.SYMBOL_MODE ,Rendition.SymbolMode.IMAGE );
rend.setValue(Rendition.SYMBOL_URL,"http://219.237.4.34:8080/samples47/images/car.gif");
// rend.setValue(Rendition.STROKE_OPACITY,0.3f );
// For lines, specify the line color and width
//Rendition.Marker marker=new Rendition.Marker(rend);
//Rendition rendLine = RenditionImpl.getDefaultRendition();
//rendLine.setValue(Rendition.STROKE_MARKERARRAY,new Rendition.Marker[]{marker});
//创建Feature,然后加入到AnnLayer。
PrimaryKey pkey = new PrimaryKey(attrib);
FeatureFactory ff = mapj.getFeatureFactory();
try {
Trace(mapj, m_PointArrary,tel);
int i;
i=m_PointArrary[0].length;
m_dPoint.x =m_PointArrary[0][i-2];
m_dPoint.y=m_PointArrary[0][i-1];
Feature feat = ff.createPoint(m_dPoint,rend,attrib, pkey);
lyrAnn.setVisible(true);
lyrAnn.addFeature(feat);
BaseLabelProperties blp = new BaseLabelProperties();
blp = lyrAnn.getLabelProperties();
blp.setLabelExpression(columns[0]);
lyrAnn.setLabelProperties(blp);
lyrAnn.setAutoLabel(true);
} catch (Exception ec) {
ec.printStackTrace();
return false;
}
return true;
}
/*//////////////////////////////////////////////////////////////////////////////////////////////////
轨迹回放显示轨迹
///////////////////////////////////////////////////////////////////////////////////////////////////*/
public boolean Trace(MapJ mapj,double[][] m_PointArrary,String tel)
{
String StrTrace="trace";
Layer lyrTrace;
FeatureFactory ff = mapj.getFeatureFactory();
Attribute att[] = new Attribute[1];
att[0] = new Attribute(tel);
Rendition rend = RenditionImpl.getDefaultRendition();
rend.setValue(Rendition.STROKE, Color.black);
rend.setValue(Rendition.STROKE_WIDTH, 2);
rend.setValue(Rendition.STROKE_OPACITY,0.3f );
int type = 1;
Feature retFeature;
if (mapj.getLayers().getLayer(StrTrace)!=null)
{
lyrTrace = mapj.getLayers().getLayer(StrTrace);
if (!lyrTrace.isAnnotationLayer()) return false;
try {
ArrayList columns_a = new ArrayList();
TableInfo tabInfo = lyrTrace.getTableInfo();
for (int i=0; i<tabInfo.getColumnCount();++i) {
columns_a.add(tabInfo.getColumnName(i));
}
RewindableFeatureSet rFtrSet = new RewindableFeatureSet(lyrTrace.searchAll(columns_a, null));
Feature ftr = rFtrSet.getNextFeature();
while (ftr != null) {
lyrTrace.removeFeature(ftr.getPrimaryKey());
ftr = rFtrSet.getNextFeature();
}
rFtrSet.dispose();
} catch (Exception ed) {
ed.printStackTrace();
return false;
}
}
else
{
try {
AnnotationTableDescHelper annTableDesc = new AnnotationTableDescHelper(StrTrace);
AnnotationDataProviderHelper dpHelper = new AnnotationDataProviderHelper();
LocalDataProviderRef dpRef = new LocalDataProviderRef(dpHelper);
lyrTrace = mapj.getLayers().insert(dpRef, annTableDesc, 0, StrTrace);
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
try
{
PrimaryKey pkey = new PrimaryKey(att[0]);
int i=m_PointArrary[0].length;
//System.out.println(m_PointArrary[0][i-2]);
retFeature = ff.createPolyLine(m_PointArrary, rend, null, att, pkey);
//lyrTrace.removeFeature(pkey);
lyrTrace.addFeature(retFeature);
lyrTrace.setAutoLabel(true);
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
/******************************end***************************/
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// response.setContentType(CONTENT_TYPE);
response.setContentType("text/html;charset=GBK");
// request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>MapperServlet</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// response.setContentType(CONTENT_TYPE);
response.setContentType("text/html;charset=UTF-8");
// request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>MapperServlet</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a POST. This is the reply.</p>");
out.println("</body></html>");
}
//Clean up resources
public void destroy() {
}
}
/******************************************************************************
* Vector columns = new Vector();
Feature ftr;
Geometry geom;
DoubleRect rect;
DoublePoint dblPnt;
PointGeometry pntGeometry;
VectorGeometry vectorGeometry;
PointList pntList;
Attribute attrib;
int attribCount;
// Get the Table information from the layer
TableInfo tabInfo = m_Layer.getTableInfo();
// fill vector with Column names
for (int i=0;i<tabInfo.getColumnCount();++i)
{
columns.addElement(tabInfo.getColumnName(i));
}
// Perform a search to get the Features(records) from the layer
RewindableFeatureSet rFtrSet = new RewindableFeatureSet(m_Layer.searchAll(columns, null));
// get the first attribute
ftr=rFtrSet.getNextFeature();
// then loop through all features in the layer
while (ftr!=null)
{
// get the first attribute (columnData) from the feature
// Note: If you want to re-use the Attribute object later on
// (after the getNextFeature loop), you would need to make a copy of
// the Attribute object, using the copy constructor.
attrib = ftr.getAttribute(0);
// get a count of all attributes in the layer
attribCount = ftr.getAttributeCount();
// get the reference to the geographic info from the feature
geom = ftr.getGeometry();
// check to see if the geographic object is a Point
if (geom.getType()==Geometry.TYPE_POINT)
{
// Cast the general geometry to a point geometry
pntGeometry = (PointGeometry)geom;
// get the minimum bounding rectangle for the feature
rect = pntGeometry.getBounds();
// get the x,y location where the features label will be anchored
dblPnt = pntGeometry.getLabelPoint(null);
}
else
{
// Cast the general geometry to a Vector geometry
vectorGeometry = (VectorGeometry)geom;
// get the minimum bounding rectangle for the feature
rect = vectorGeometry.getBounds();
// get the x,y location where the features label will be anchored
dblPnt = vectorGeometry.getLabelPoint(null);
double[] pnts;
int offset=0;
int numPts;
// Loop through all the point groups and then put the points
// into an array
for (int i=0;i<vectorGeometry.getPointListCount();++i)
{
// Get the next Point List
pntList = vectorGeometry.getNextPointList();
// determine the number of Points in the point group
numPts = pntList.getPointCount();
// Create the point array large enough to hold all the points
pnts = new double[numPts*2];
// Call getNextPoints which will put the points into the array
pntList.getNextPoints(pnts, offset, numPts);
}
}
// Get the next feature
ftr=rFtrSet.getNextFeature();
}
// Rewind the FeatureSet to prepare for future use
rFtrSet.rewind();
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -