国学参考
网站地图 高级搜索 RSS订阅
电信 网通 铁通 美国 收藏本站
首页 | 地理资讯 | 地理文摘 | 环境气象 | 学习园地 | 地理百科 | 地域行政 | 地理资源 | geography | 专题 | 地理论坛
当前位置:首页>地理文摘>技术应用>文章内容
用java读DXF文件(ReadWorldmap.java)源码
来源: 作者:国学 发布时间:1970-01-01






//ReadWorldmap.java
//读取世界图对象
import java.io.*;
import java.util.*;
import java.net.*;

public class ReadWorldmap
{
private URL url;
private String FileName;
private InputStream inStream;
private InputStreamReader inStreamReader;
private BufferedReader bReader;

private String temp,temp1,temp2,temp3;
private int line;

public Worldmap worldmap=new Worldmap();

//构造函数,context是索引文件所在的URL,spec是世界图名
public ReadWorldmap(URL context,String SetName,String spec)
{
line=0;
this.url=context;
FileName=spec .NDX;
try
{
//inStream=(new URL(url,\\ SetName \\ spec \\ FileName)).openStream();
inStream=(new URL(url,SetName / spec / FileName)).openStream();
inStreamReader=new InputStreamReader(inStream);
bReader=new BufferedReader(inStreamReader);
// System.out.println( :) Begin read file FileName);
}
catch(IOException e)
{ www_chinageog_com
// System.out.println(Connection was not found. Can not read file FileName);
}
}
//****************************************************************************
private void error_report()
{
//System.out.println( :< error appear at line line in file FileName);
}

//世界图初始化函数,返回一个世界图对象,在这个世界图对象中,仅包含世界图的基本属性,
//如坐标、放大倍数、层的信息等,而不包含具体的实体信息。
public Worldmap initialise()
{
boolean mainFlag=true;
double wmy1=0,wmy2=100; //临时变量

while(mainFlag)
{
try
{
line ;
temp=new String(bReader.readLine());
}
catch(IOException e) { error_report();}
temp=temp.trim();
StringTokenizer st=new StringTokenizer(temp,<>,);
temp1=st.nextToken();

if(temp1.equals(NAME))
{
temp2=st.nextToken();
temp2=temp2.trim();
worldmap._worldmap_name =temp2;

continue;
}

if(temp1.equals(DEC_COUNT))
{

temp2=st.nextToken();
temp2=temp2.trim();
//worldmap.dec_count=Integer.valueOf(temp2).intValue();

www.chinageog.com



continue;
}

if(temp1.equals(BEGIN_WC))
{
temp2=st.nextToken();
temp2=temp2.trim();
temp3=st.nextToken();
temp3=temp3.trim();

worldmap._begin_world_coordinate_x=Double.valueOf(temp2).doubleValue();
// worldmap._begin_world_coordinate_y=Double.valueOf(temp3).doubleValue();
wmy2=Double.valueOf(temp3).doubleValue();

continue;
}

if(temp1.equals(END_WC))
{

temp2=st.nextToken();
temp2=temp2.trim();
temp3=st.nextToken();
temp3=temp3.trim();

worldmap._end_world_coordinate_x=Double.valueOf(temp2).doubleValue();
// worldmap._end_world_coordinate_y=Double.valueOf(temp3).doubleValue();
wmy1=Double.valueOf(temp3).doubleValue();

continue;
}

if(temp1.equals(DECLUTTER))
{
boolean dec_Flag=true; //标志变量
Declutter tempDeclutter=new Declutter();
double decy1=0,decy2=100; //临时变量

while(dec_Flag)
{
try
{
temp=new String(bReader.readLine());
}
catch(IOException e) { error_report(); } www_chinageog_com
temp=temp.trim();
StringTokenizer st1=new StringTokenizer(temp,<>,);
temp1=st1.nextToken();
temp1=temp1.trim();

if(temp1.equals(NO))
{
temp2=st1.nextToken();
temp2=temp2.trim();

// tempDeclutter.index=temp2;

continue;
}

if( temp1.equals(NAME))
{
temp2=st1.nextToken();
temp2=temp2.trim();

tempDeclutter._declutter_name=temp2;
continue;
}

if(temp1.equals(SEG_COUNT))
{
temp2=st1.nextToken();
temp2=temp2.trim();

// tempDeclutter.segment_number=Integer.valueOf(temp2).intValue();
continue;
}

if(temp1.equals(BEGIN_WC))
{
temp2=st1.nextToken();
temp2=temp2.trim();
temp3=st1.nextToken();
temp3=temp3.trim();

tempDeclutter._begin_world_coordinate_x=Double.valueOf(temp2).doubleValue();
// tempDeclutter._begin_world_coordinate_y=Double.valueOf(temp3).doubleValue();
decy2=Double.valueOf(temp3).doubleValue();

continue;
}

if(temp1.equals(END_WC))
{
temp2=st1.nextToken();
chinageog

temp2=temp2.trim();
temp3=st1.nextToken();
temp3=temp3.trim();

tempDeclutter._end_world_coordinate_x=Double.valueOf(temp2).doubleValue();
// tempDeclutter._end_world_coordinate_y=Double.valueOf(temp3).doubleValue();
decy1=Double.valueOf(temp3).doubleValue();

continue;
}

if(temp1.equals(MAX_ZOOM))
{
temp2=st1.nextToken();
temp2=temp2.trim();

tempDeclutter._display_zoomfactor_max=Double.valueOf(temp2).doubleValue();
continue;
}

if(temp1.equals(MIN_ZOOM))
{
temp2=st1.nextToken();
temp2=temp2.trim();

tempDeclutter._display_zoomfactor_min=Double.valueOf(temp2).doubleValue()*1.1;
continue;
}

if(temp1.equals(SEGMENT))
{
boolean seg_Flag=true;
Segment tempSegment=new Segment();
double segy1=0,segy2=100; //临时变量

while(seg_Flag)
{
try
{
temp=new String(bReader.readLine());
}
catch(IOException e) { error_report();}
共2页: 上一页 1 [2] 下一页
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
§最新评论:
热点文章
·俺们这里需要购置GPS接收机(大
·1997年世界编程大赛时的参赛作品
·一名Delphi程序员的开发习惯
·海量影像数据库管理系统解决方案
·网民必备之七种武器
相关文章
·海量影像数据库管理系统解决方案
·网民必备之七种武器
·一名Delphi程序员的开发习惯
·1997年世界编程大赛时的参赛作品
·俺们这里需要购置GPS接收机(大
Copyright © 2006 国学参考  All Rights Reserved Power by:HeadWind