package application;
/* Copyright 2014 Esri
All rights reserved under the copyright laws of the United States
and applicable international laws, treaties, and conventions.
You may freely redistribute and use this sample code, with or
without modification, provided you include the original copyright
notice and use restrictions.
See the use restrictions.*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.esri.client.local.ArcGISLocalDynamicMapServiceLayer;
import com.esri.toolkit.overlays.DrawingCompleteEvent;
import com.esri.toolkit.overlays.DrawingCompleteListener;
import com.esri.toolkit.overlays.DrawingOverlay;
import com.esri.toolkit.overlays.DrawingOverlay.DrawingMode;
import com.esri.toolkit.utilities.ResultPanel;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.Point;
import com.esri.core.map.Feature;
import com.esri.core.map.Graphic;
import com.esri.core.symbol.SimpleFillSymbol;
import com.esri.core.symbol.SimpleLineSymbol;
import com.esri.core.symbol.SimpleMarkerSymbol;
import com.esri.core.symbol.SimpleMarkerSymbol.Style;
import com.esri.core.tasks.identify.IdentifyParameters;
import com.esri.core.tasks.identify.IdentifyResult;
import com.esri.core.tasks.identify.IdentifyTask;
import com.esri.map.ArcGISDynamicMapServiceLayer;
import com.esri.map.GraphicsLayer;
import com.esri.map.JMap;
import com.esri.map.LayerInitializeCompleteEvent;
import com.esri.map.LayerInitializeCompleteListener;
import com.esri.map.MapOverlay;
import com.esri.runtime.ArcGISRuntime;
/***
* This application shows how to perform the Identify task.
* An <code>IdentifyTask</code> is created using a local dynamic layer
* (<code>ArcGISLocalDynamicMapServiceLayer</code>) and in this
* case the task is executed synchronously on the local server.
*/
public class LocalIdentify {
private static String FSP = System.getProperty("file.separator");
private GraphicsLayer graphicsLayer;
// components
private JMap map;
private ArcGISLocalDynamicMapServiceLayer dynamicLayer;
// private ArcGISDynamicMapServiceLayer dynamicLayer;
private JComponent contentPane;
private ResultPanel resultPanel;
private Geometry geometry;
private Graphic graphic;
// UI constants for sizing
private static final int PANEL_WIDTH = 250;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
public LocalIdentify() {
}
// ------------------------------------------------------------------------
// Core functionality
// ------------------------------------------------------------------------
/**
* Perform the Identify task on the geometry - the clicked point, in this
* case.
* @param geometry
* @return
*/
private River identify(Geometry geometry) {
IdentifyParameters identifyparam = new IdentifyParameters();
identifyparam.setGeometry(geometry);
identifyparam.setMapExtent(map.getExtent());
identifyparam.setSpatialReference(map.getSpatialReference());
identifyparam.setMapHeight(map.getHeight());
identifyparam.setMapWidth(map.getWidth());
identifyparam.setLayerMode(IdentifyParameters.VISIBLE_LAYERS);
identifyparam.setDPI(ArcGISRuntime.getDPI());
IdentifyTask task = new IdentifyTask(dynamicLayer.getUrl());
try {
IdentifyResult[] results = task.execute(identifyparam);
//得到所有graphic下的河道信息
River river=displayResults(results);
return river;
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(contentPane, wrap(e.getMessage()));
}
return null;
}
/**
* @param results
* @return 获取river 的属性
*/
private River displayResults(IdentifyResult[] results) {
// write the new title for our query results panel
resultPanel.setTitle(results.length + " Identify result" + (results.length == 1 ? "" : "s")+":");
// write the results to our text area
StringBuilder text = new StringBuilder();
StringBuilder riverID=new StringBuilder();
StringBuilder riverName=new StringBuilder();
for (int i = 0; i < results.length; i++) {
IdentifyResult result = results[i];
// String[] keys= {"OBJECTID","RefName"};
String key="",value="",id="";
String layername =result.getLayerName();
/* key=(layername.equals("标注")&& layername != null)?keys[1]:keys[0];
String resultString = result.getAttributes().get(
result.getDisplayFieldName()key)
+ " (" + result.getLayerName() + ")";
text.append(resultString + "\n");*/
//add edit by own
if(layername!=null){
if(!layername.equals("标注")){
id=(String) result.getAttributes().get("OBJECTID");
}else{
value=(String) result.getAttributes().get("RefName");
}
}
if (value==""){
// System.out.println(id);
riverID.append(id);
}else{
// System.out.println(value);
riverName.append(value);
}
}
System.out.println("河道信息:"+riverID+";"+riverName);
text.append("河道信息:"+riverID+";"+riverName);
ReadfromExcel baseinfo=new ReadfromExcel();
List<?> list=new ArrayList<String>();
//获取正确的河段名称。
try {
list=baseinfo.getExcelAsFile("E:/rivertest.xls");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int i,length=list.size();
String name="";
for (i=0;i<length-1;i++){
String base=(String) list.get(i);
String target=riverName.toString();
//将无序的属性进行替换成正确有序的属性
ExportToExcel exc=new ExportToExcel();
if (exc.valueCorrect(target, base)){
name=base;break;
}else{
name=target;continue;
}
}
River river=new River(riverID.toString(),name);//riverName.toString()
System.out.println(name);
resultPanel.setContent(text.toString());
resultPanel.setVisible(true);
return river;
}
/**
* Map overlay to get the clicked point and call the
* identify method on it.
*/
private class MouseClickedOverlay extends MapOverlay {
private static final long serialVersionUID = 1L;
@Override
public void onMouseClicked(MouseEvent arg0) {
try {
Point mapPoint = map.toMapPoint(arg0.getX(), arg0.getY());
identify(mapPoint);
} finally {
super.onMouseClicked(arg0);
}
}
}
// ------------------------------------------------------------------------
// Static methods
// ------------------------------------------------------------------------
public static void main(S
将CAD中的标注转化为ArcGIS中相应地理要素的属性
2星 需积分: 47 96 浏览量
2017-11-29
12:00:20
上传
评论 6
收藏 60KB RAR 举报
逸然健在
- 粉丝: 112
- 资源: 6
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈