• 大小: 116KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: Java
  • 标签: JAVA  iObjects  Supermap  

资源简介

在实际应用中经常会遇到面对象合并,如东三省合并为东北区。该范例实现了对象运算中的求交,合并,擦除,裁剪等功能。

资源截图

代码片段和文件信息

package geometryOperate;

import java.awt.Color;
import java.io.File;

import com.supermap.data.CursorType;
import com.supermap.data.DatasetVector;
import com.supermap.data.Datasource;
import com.supermap.data.DatasourceConnectionInfo;
import com.supermap.data.EngineType;
import com.supermap.data.Geostyle;
import com.supermap.data.Geometrist;
import com.supermap.data.Geometry;
import com.supermap.data.Recordset;
import com.supermap.data.Workspace;
import com.supermap.mapping.Trackinglayer;
import com.supermap.ui.MapControl;

public class GeometryOperate
{

private Workspace myWorkspace;
private MapControl myMapControl;
private Datasource datasource;
private DatasetVector vector;
private Geometry geometry1;
private Geometry geometry2;
private Geometry resultGM;
private Trackinglayer trackinglayer;

public  GeometryOperate(Workspace workspaceMapControl mapControl)
{
this.myWorkspace=workspace;
this.myMapControl=mapControl;
loadData();
}
/**
 * 加载数据
 */
private void loadData()
{
try
{
File file=new File(“.“);
String str=file.getAbsolutePath().replace(“\\““/“);
String path=str.substring(0 str.length()-1)+“data/data.udb“;
// 打开数据源
DatasourceConnectionInfo conInfo = new DatasourceConnectionInfo(path “data“ ““);
conInfo.setEngineType(EngineType.UDB);
datasource=myWorkspace.getDatasources().open(conInfo);
vector=(DatasetVector) datasource.getDatasets().get(0);
myMapControl.getMap().setWorkspace(myWorkspace);
myMapControl.getMap().getlayers().add(vector true);
myMapControl.getMap().viewEntire();
myMapControl.getMap().refresh();
trackinglayer=myMapControl.getMap().getTrackinglayer();
getGeometry();

catch (Exception e)
{
System.out.println(e.getMessage());
}
}
/**
 * 获取两个面对象
 */
private void getGeometry()
{
try
{
Recordset recordset1=vector.query(“SMID=1“ CursorType.STATIC);
Recordset recordset2=vector.query(“SMID=2“ CursorType.STATIC);
geometry1=recordset1.getGeometry();
geometry2=recordset2.getGeometry();
recordset1.dispose();
recordset2.dispose();
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
/**
 * 设置结果对象的风格
 */
private Geostyle setGeostyle()
{
Geostyle style=new Geostyle();
style.setFillForeColor(Color.red);
style.setFillOpaqueRate(36);
return style;
}
/**
 * 两个面对象求交
 */
public void intersect()
{
try
{
trackinglayer.clear();
resultGM=Geometrist.intersect(geometry1 geometry2);
resultGM.setstyle(setGeostyle());
trackinglayer.add(resultGM “相交“);
myMapControl.getMap().refresh();

catch (Exception e)
{
System.out.println(e.getMessage());
}
}
/**
 * 两个面对象合并
 */
public void union()
{
try
{
trackinglayer.clear();
resultGM=Geometrist.union(geometry1 geometry2);
resultGM.setstyle(setGeostyle());
trackinglayer.add(resultGM 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-10-26 17:04  GeometryOperate\
     文件         746  2012-10-23 13:23  GeometryOperate\.classpath
     文件         391  2012-10-23 13:21  GeometryOperate\.project
     目录           0  2012-10-23 13:21  GeometryOperate\.settings\
     文件         629  2012-10-23 13:21  GeometryOperate\.settings\org.eclipse.jdt.core.prefs
     目录           0  2012-10-23 14:22  GeometryOperate\bin\
     目录           0  2012-10-23 15:18  GeometryOperate\bin\geometryOperate\
     文件        5539  2012-10-23 15:27  GeometryOperate\bin\geometryOperate\GeometryOperate.class
     文件         665  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$1.class
     文件        1357  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$2.class
     文件         853  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$3.class
     文件         849  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$4.class
     文件         849  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$5.class
     文件         848  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$6.class
     文件         849  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe$7.class
     文件        3828  2012-10-23 15:21  GeometryOperate\bin\geometryOperate\Mainframe.class
     目录           0  2012-10-23 15:28  GeometryOperate\data\
     文件        1344  2012-10-23 13:57  GeometryOperate\data\data.udb
     文件       81920  2012-10-23 13:57  GeometryOperate\data\data.udd
     文件      111630  2012-10-26 17:04  GeometryOperate\GeometryOperate.pdf
     目录           0  2012-10-23 13:22  GeometryOperate\src\
     目录           0  2012-10-23 13:24  GeometryOperate\src\geometryOperate\
     文件        4031  2012-10-23 15:27  GeometryOperate\src\geometryOperate\GeometryOperate.java
     文件        3589  2012-10-23 15:21  GeometryOperate\src\geometryOperate\Mainframe.java

评论

共有 条评论