- 浏览: 230399 次
- 性别:
- 来自: beijing
文章分类
package com.hdmap.fymas; import java.io.IOException; import com.esri.arcgis.geodatabase.Feature; import com.esri.arcgis.geodatabase.FeatureClass; import com.esri.arcgis.geodatabase.FeatureCursor; import com.esri.arcgis.geodatabase.Field; import com.esri.arcgis.geodatabase.Fields; import com.esri.arcgis.geodatabase.IDataset; import com.esri.arcgis.geodatabase.IDatasetName; import com.esri.arcgis.geodatabase.IEnumDataset; import com.esri.arcgis.geodatabase.IEnumDatasetName; import com.esri.arcgis.geodatabase.IFeatureBuffer; import com.esri.arcgis.geodatabase.IFeatureCursor; import com.esri.arcgis.geodatabase.IWorkspace; import com.esri.arcgis.geodatabase.esriDatasetType; import com.esri.arcgis.geodatabase.esriFieldType; import com.esri.arcgis.geodatabasedistributed.GeoDataServer; import com.esri.arcgis.geometry.IPoint; import com.esri.arcgis.geometry.Point; import com.esri.arcgis.interop.AutomationException; import com.esri.arcgis.server.IServerContext; import com.esri.arcgis.server.IServerObjectManager; import com.esri.arcgis.server.ServerConnection; import com.esri.arcgis.system.Cleaner; import com.esri.arcgis.system.ServerInitializer; public class GeoDataServerMain { private static String user = "cmt";// private static String password = "a";// private static String domain = "172.16.17.156"; private static String host = "172.16.17.156"; private static String servicesName = "qin/usaqiny"; private static ServerConnection conn = null; private static IServerContext serverContext = null; private static IServerObjectManager som = null; private static GeoDataServer gdbserver = null; private static IWorkspace workspace = null; public static void initGeoDataServer() { /*** 连接到ArcGISSever */ try { new ServerInitializer().initializeServer(domain, user, password); conn = new ServerConnection(); conn.connect(host); som = conn.getServerObjectManager(); serverContext = som.createServerContext(servicesName, "GeoDataServer"); gdbserver = (GeoDataServer) serverContext.getServerObject(); workspace = gdbserver.getDefaultWorkingWorkspace(); System.out.print("已连接到ArcGIS Sever"); } catch (Exception e) { e.printStackTrace(); gdbserver = null; workspace = null; som = null; } } public static void main(String[] args) throws Exception { // GeoDataServerMain it = new GeoDataServerMain(); initGeoDataServer(); browseFileGDB(workspace); insertFeaturesUsingCursor(workspace); browseFileGDB(workspace); serverContext.releaseContext(); } /** * 显示所有的图层 * @param workspace */ public static void browseFileGDB(IWorkspace workspace) { try { IEnumDatasetName enumDatasetName = workspace .getDatasetNames(esriDatasetType.esriDTAny); IDatasetName dsName = enumDatasetName.next(); while (dsName != null) { System.out.println("Dataset Name: " + dsName.getName()); dsName = enumDatasetName.next(); } IEnumDataset enumDataset = workspace .getDatasets(esriDatasetType.esriDTFeatureClass); IDataset ds = enumDataset.next(); while (ds != null) { FeatureClass fClass = new FeatureClass(ds); query(fClass); int fCount = fClass.featureCount(null); System.out.println("FeatureClass " + fClass.getAliasName() + " has " + fCount + " features."); ds = enumDataset.next(); } } catch (Exception e) { e.printStackTrace(); } } /**查询数据 * @param featureClass * @throws AutomationException * @throws IOException */ public static void query(FeatureClass featureClass) throws AutomationException, IOException { FeatureCursor featureCursor = new FeatureCursor(featureClass.search( null, true)); Feature feature = (Feature) featureCursor.nextFeature(); Fields fields = (Fields) featureCursor.getFields(); int fieldCount = fields.getFieldCount(); for (int index = 0; index < fieldCount; index++) { Field field = (Field) fields.getField(index); String fieldName = field.getName(); System.out.print(fieldName + "\t"); } System.out.println(); while (feature != null) { StringBuffer row = new StringBuffer(); for (int index = 0; index < fieldCount; index++) { int fieldType = feature.getFields().getField(index).getType(); switch (fieldType) { case esriFieldType.esriFieldTypeDate: case esriFieldType.esriFieldTypeDouble: case esriFieldType.esriFieldTypeGlobalID: case esriFieldType.esriFieldTypeGUID: case esriFieldType.esriFieldTypeInteger: case esriFieldType.esriFieldTypeOID: case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeSmallInteger: case esriFieldType.esriFieldTypeString: row.append(feature.getValue(index) + "\t"); break; case esriFieldType.esriFieldTypeBlob: row.append("(blob)" + "\t"); break; case esriFieldType.esriFieldTypeGeometry: row.append("(geometry)" + "\t"); break; case esriFieldType.esriFieldTypeRaster: row.append("(raster)" + "\t"); break; } } if (row.length() > 0) { System.out.println(row); } feature = (Feature) featureCursor.nextFeature(); } } /** * 插入数据 * @param workspace * @throws Exception */ private static void insertFeaturesUsingCursor(IWorkspace workspace) throws Exception { IEnumDataset enumDataset = workspace .getDatasets(esriDatasetType.esriDTFeatureClass); IDataset ds = enumDataset.next();// 这里就有一个图层,所以就这么写了,应该获得图层然后进行操作 while (ds != null) { FeatureClass featureClass = new FeatureClass(ds); IFeatureBuffer featureBuffer = featureClass.createFeatureBuffer(); IFeatureCursor insertCursor = featureClass .IFeatureClass_insert(false); // 这里是关键 // 不能 Point point= new Point(); IPoint point = (IPoint) serverContext .createObject(Point.getClsid()); point.setX(100); point.setY(200); featureBuffer.setShapeByRef(point); insertCursor.insertFeature(featureBuffer); ds = enumDataset.next(); insertCursor.flush(); Cleaner.release(insertCursor); } } }
package com.hdmap.fymas; import java.io.IOException; import java.util.List; import com.esri.arcgis.carto.FeatureLayer; import com.esri.arcgis.carto.IFeatureLayer; import com.esri.arcgis.geodatabase.Feature; import com.esri.arcgis.geodatabase.FeatureClass; import com.esri.arcgis.geodatabase.FeatureCursor; import com.esri.arcgis.geodatabase.Field; import com.esri.arcgis.geodatabase.Fields; import com.esri.arcgis.geodatabase.IDataset; import com.esri.arcgis.geodatabase.IDatasetName; import com.esri.arcgis.geodatabase.IEnumDataset; import com.esri.arcgis.geodatabase.IEnumDatasetName; import com.esri.arcgis.geodatabase.IFeatureBuffer; import com.esri.arcgis.geodatabase.IFeatureClass; import com.esri.arcgis.geodatabase.IFeatureCursor; import com.esri.arcgis.geodatabase.IWorkspace; import com.esri.arcgis.geodatabase.esriDatasetType; import com.esri.arcgis.geodatabase.esriFieldType; import com.esri.arcgis.geodatabasedistributed.GeoDataServer; import com.esri.arcgis.geometry.IPoint; import com.esri.arcgis.geometry.Point; import com.esri.arcgis.interop.AutomationException; import com.esri.arcgis.server.IServerContext; import com.esri.arcgis.server.IServerObjectManager; import com.esri.arcgis.server.ServerConnection; import com.esri.arcgis.system.Cleaner; import com.esri.arcgis.system.ServerInitializer; import com.hdmap.fymas.fire.bean.FirePoint; import com.hdmap.fymas.utils.ReadFromFileUtil; public class GeoDataServerMain { private static String user = "cmt";// private static String password = "a";// private static String domain = "172.16.17.156"; private static String host = "172.16.17.156"; private static String servicesName = "qin/usaqiny"; private static ServerConnection conn = null; private static IServerContext serverContext = null; private static IServerObjectManager som = null; private static GeoDataServer gdbserver = null; private static IWorkspace workspace = null; public static void initGeoDataServer() { /*** 连接到ArcGISSever */ try { new ServerInitializer().initializeServer(domain, user, password); conn = new ServerConnection(); conn.connect(host); som = conn.getServerObjectManager(); serverContext = som.createServerContext(servicesName, "GeoDataServer"); gdbserver = (GeoDataServer) serverContext.getServerObject(); workspace = gdbserver.getDefaultWorkingWorkspace(); System.out.print("已连接到ArcGIS Sever"); } catch (Exception e) { e.printStackTrace(); gdbserver = null; workspace = null; som = null; } } public static void main(String[] args) throws Exception { // GeoDataServerMain it = new GeoDataServerMain(); initGeoDataServer(); browseFileGDB(workspace); String fileName = "D:/FIR_PLST_FY3A_MERSI_1000M_EJ_P001_20110426024500.TXT"; List alist = ReadFromFileUtil.readFirePointByLines(fileName); System.out.println(alist); // insertFeaturesUsingCursor(workspace); insertFirePoint(workspace, alist); browseFileGDB(workspace); serverContext.releaseContext(); } /** * 插入数据 * * @param workspace * @throws Exception */ @SuppressWarnings("unused") private static void insertFeaturesUsingCursor(IWorkspace workspace, String featureName) throws Exception { FeatureClass featureClass = getFeatureClassByName(workspace, featureName); IFeatureBuffer featureBuffer = featureClass.createFeatureBuffer(); IFeatureCursor insertCursor = featureClass.IFeatureClass_insert(false); // 这里是关键 // 不能 Point point= new Point(); IPoint point = (IPoint) serverContext.createObject(Point.getClsid()); point.setX(100); point.setY(200); featureBuffer.setShapeByRef(point); insertCursor.insertFeature(featureBuffer); insertCursor.flush(); Cleaner.release(insertCursor); } /** * 根据FeatureClassName 获得FeatureClass * * @param workspace * @param FeatureClassName * @return * @throws AutomationException * @throws IOException */ public static FeatureClass getFeatureClassByName(IWorkspace workspace, String FeatureClassName) throws AutomationException, IOException { IEnumDataset enumDataset = workspace .getDatasets(esriDatasetType.esriDTFeatureClass); IDataset ds = enumDataset.next();// FeatureClass featureClass = null; while (ds != null) { if (FeatureClassName.equals(ds.getName())) { featureClass = new FeatureClass(ds); } ds = enumDataset.next(); } return featureClass; } /** * 显示所有的图层 * * @param workspace */ public static void browseFileGDB(IWorkspace workspace) { try { IEnumDatasetName enumDatasetName = workspace .getDatasetNames(esriDatasetType.esriDTAny); IDatasetName dsName = enumDatasetName.next(); while (dsName != null) { System.out.println("Dataset Name: " + dsName.getName()); dsName = enumDatasetName.next(); } IEnumDataset enumDataset = workspace .getDatasets(esriDatasetType.esriDTFeatureClass); IDataset ds = enumDataset.next(); while (ds != null) { FeatureClass fClass = new FeatureClass(ds); query(fClass); int fCount = fClass.featureCount(null); System.out.println("FeatureClass " + fClass.getAliasName() + " has " + fCount + " features."); ds = enumDataset.next(); } } catch (Exception e) { e.printStackTrace(); } } /** * 查询数据 * * @param featureClass * @throws AutomationException * @throws IOException */ public static void query(FeatureClass featureClass) throws AutomationException, IOException { FeatureCursor featureCursor = new FeatureCursor(featureClass.search( null, true)); Feature feature = (Feature) featureCursor.nextFeature(); Fields fields = (Fields) featureCursor.getFields(); int fieldCount = fields.getFieldCount(); for (int index = 0; index < fieldCount; index++) { Field field = (Field) fields.getField(index); String fieldName = field.getName(); System.out.print(fieldName + "\t"); } System.out.println(); while (feature != null) { StringBuffer row = new StringBuffer(); for (int index = 0; index < fieldCount; index++) { int fieldType = feature.getFields().getField(index).getType(); switch (fieldType) { case esriFieldType.esriFieldTypeDate: case esriFieldType.esriFieldTypeDouble: case esriFieldType.esriFieldTypeGlobalID: case esriFieldType.esriFieldTypeGUID: case esriFieldType.esriFieldTypeInteger: case esriFieldType.esriFieldTypeOID: case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeSmallInteger: case esriFieldType.esriFieldTypeString: row.append(feature.getValue(index) + "\t"); break; case esriFieldType.esriFieldTypeBlob: row.append("(blob)" + "\t"); break; case esriFieldType.esriFieldTypeGeometry: row.append("(geometry)" + "\t"); break; case esriFieldType.esriFieldTypeRaster: row.append("(raster)" + "\t"); break; } } if (row.length() > 0) { System.out.println(row); } feature = (Feature) featureCursor.nextFeature(); } } /** * 插入火点数据 * * @param workspace * @throws Exception */ @SuppressWarnings("unused") private static void insertFirePoint(IWorkspace workspace, List<FirePoint> fpList) throws Exception { // IEnumDataset enumDataset = workspace // .getDatasets(esriDatasetType.esriDTFeatureClass); // IDataset ds = enumDataset.next();// 这里就有一个图层,所以就这么写了,应该获得图层然后进行操作 String fName = "fire_p"; // while (ds != null) { FeatureClass featureClass = getFeatureClassByName(workspace, fName); // FeatureClass featureClass = new FeatureClass(ds); IFeatureBuffer featureBuffer = featureClass.createFeatureBuffer(); IFeatureCursor insertCursor = featureClass.IFeatureClass_insert(false); for (int i = 0; i < fpList.size(); i++) { // 这里是关键 FirePoint fp = fpList.get(i); IPoint point = (IPoint) serverContext .createObject(Point.getClsid()); point.setX(fp.getX()); point.setY(fp.getY()); featureBuffer.setShapeByRef(point); insertCursor.insertFeature(featureBuffer); } // ds = enumDataset.next(); insertCursor.flush(); Cleaner.release(insertCursor); // } } }
发表评论
-
二进制 授权管理 java
2013-09-09 12:52 912package org.qincy.binary; ... -
com.richfit.bi.quartz 定时执行示例
2013-04-12 15:39 01 内含jetty 配置,下载jetty 依赖包,算了,还是提 ... -
geoserver 在liunix 系统下 地图乱码问题解决
2013-01-04 13:20 1246... -
openscales1.2 实现加载arcgis 切片
2012-09-14 12:30 2491package org.openscales.core.lay ... -
重写openalyers 的方法,加载天地图瓦片数据
2012-06-20 09:16 6370将TiandituLayer 加载到OpenLayers.js ... -
利用工具将shp文件导入到oracle spatial中
2012-05-21 14:20 43931 下载shp2sdo 工具,将工具放在 oracle按照目录 ... -
oracle s
2012-06-20 09:18 974<pre name="code" c ... -
oracle spatial 空间数据学习
2012-05-17 16:09 1786最近项目使用 空间数据库 oracle spatial ... -
在ArcGIS 10 Desktop中打开Google Map,BingMap
2012-04-13 15:56 1555安装使用: 1 双击ArcBruTile_0.2.zip ... -
Arcgis object for java 访问栅格数据,使用GP工具,进行栅格矢量化---栅格矢量化面。
2012-06-20 09:17 4154直接贴代码了,不多解释了。 1、栅格数据的 ... -
svn 删除注册表
2012-02-11 12:02 1566svn 删除注册表 -
Flex BlazeDS java 项目
2011-12-12 17:21 1101根据网上的例子 ,写的 flex BlazeDS 框架与 ... -
ArcObject中的游标Cursor的理解
2011-05-04 10:48 1294cursor给人的第一 ... -
esri arcobj 开发for java
2011-04-15 14:04 10801、查找数据 1)、利用FeaturCursor进行空间查询 ... -
ESRI Flex GIS开发连载(1) ---环境搭建
2011-03-25 10:29 18761首先 用 argis server 发布一个 s ... -
工具类
2011-02-18 14:05 979英文数字转换为 中文数字 public class Mon ... -
junit 4 spring 自动化测试
2010-12-13 16:08 16391 添加jar ,依赖jar 包围 spring-test, ... -
在tomcat 发布,去掉项目名称
2010-11-17 09:53 19681 找到 server.xml 配置= ... -
掉字段内容包含的空格
2010-09-27 10:17 980使用replace函数去掉字段内容包含的空格,例子如下: up ... -
无聊的jsti 的fn 函数(资料备份)
2010-09-25 17:16 984无聊的jsti 的fn 函数(资料备份) ...
相关推荐
- 在命令行中,定位到 AGSSOM.exe 所在的路径,例如 "C:\arcgisserver\directories\arcgisserver\tools\agsadmin"(具体路径取决于你的安装位置)。 - 输入命令 `AGSSOM.exe -admin -s <server_url> -u <username>...
在局域网环境中,当Web站点与ArcGIS Server服务不在同一台机器上时,或者是在多人协作开发的情况下需要共享同一台服务器上的服务时,就需要进行特定的配置。这种配置的目的在于确保Web站点能够顺利地访问到ArcGIS ...
首先,为了实现OpenLayers与ArcGIS Server的集成,你需要确保在创建ArcGIS Server服务时已经启用了WMS服务。这通常在Authoring或Publishing服务时完成。在ArcCatalog中,你可以选择要发布的服务,并在设置选项中勾选...
总之,ArcEngine连接ArcGIS Server服务是GIS应用开发的重要环节,它允许开发者利用服务器上的地图服务构建定制化的GIS应用程序,满足特定的业务需求。理解并熟练掌握这个过程,对于提升GIS开发技能至关重要。
然而,由于浏览器的同源策略限制,Web应用通常不能直接访问不同源(域名、协议或端口不同)的资源,这在尝试从Web应用访问ArcGIS Server服务时会遇到问题。为解决这个问题,ArcGIS Server10.2.1提供了跨域设置。 ...
在 OsgEarth 中加载谷歌卫星地图的 ArcGISServer 服务教程是指通过使用水经注万能地图下载器下载的谷歌卫星地图瓦片数据,在 ArcGIS 中发布服务,并在 OsgEarth 中加载发布好的瓦片服务。以下是相关知识点: 1. ...
### C/S平台下通过C#连接ArcGIS Server服务的知识点详解 #### 一、概述 在客户端/服务器(C/S)架构中,通过C#语言实现与ArcGIS Server的服务连接是一项重要的技术。此技术允许开发人员利用ArcGIS Server提供的...
1、停掉ArcGIS Server的服务。 2、 打开<ArcGIS Server> \framework\runtime\tomcat\conf\web.xml,注册跨域bean 3、lib下拷贝 cors-filter-2.5.jar java-property-utils-1.9.1.jar包 4、启动ArcGIS Server的服务。 5...
总的来说,访问ArcGIS Server服务的ArcEngine网络分析服务是一项涉及多个步骤和技术的复杂任务。开发者需要熟悉ArcGIS API,理解网络分析原理,并具备良好的编程和GIS应用设计能力。通过Route_GISClient这样的客户端...
ARCGIS Server服务接口设计是一份关于如何为开发者提供ARCGIS Server服务接口设计指导的文档,本文将详细解读文档所涉及的知识点。 首先,文档开篇就提出了对ARCGIS Server服务接口的总体介绍,强调了ARCGIS Server...
忘记ArcGIS Server的登录密码是很常见的现象,但通过上述步骤,您可以轻松地找回或重置密码,从而继续高效地使用ArcGIS Server进行地图服务的管理和部署。对于企业级用户来说,建议建立一套完整的密码管理机制,包括...
本篇文章将详细介绍 ArcGIS Server 中的各种服务及其功能。 1. 地图服务 (Map Service) 地图服务是 ArcGIS Server 的核心服务之一,它基于地图文档 (.mxd, .pmf) 提供地图内容的访问。地图服务可以以多种方式展示,...
ArcGis server服务迁移,不用再一个一个的重新发服务,新装好server服务器后,只需三步即可迁移,简单方便
ArcGisServer 跨网段访问问题及解决 在 ArcGisServer 中,跨网段访问问题是一个常见的问题,该问题的解决方案对许多开发者和管理员来说都是非常重要的。今天,我们将详细讨论 ArcGisServer 跨网段访问问题及解决...
《ArcGISServer服务扩展与Java深度解析》 ArcGISServer是Esri公司推出的地理信息系统(GIS)服务器产品,它允许用户通过网络共享、管理和发布地理数据与服务。Java作为一门广泛应用于企业级开发的语言,与ArcGIS...
7. **启动和验证**:安装完成后,启动ArcGIS Server服务,并通过Web浏览器访问管理界面,验证安装是否成功。 8. **发布和管理服务**:通过ArcGIS Server Manager或ArcGIS Desktop创建和发布地图服务,与其他用户...
在ArcGIS Server中,动态加载图层是一种优化地图服务性能的技术。它允许用户根据需要在运行时动态地添加、删除或更改地图中的图层,而不是一次性加载所有数据。这种技术对于处理大量数据或者需要实时更新的地图应用...
用Arcgis Server 提供的 REST API 直接调用Arcgis Server 服务状态