GE Smallworld开发(001建立数据库)

来源:互联网 发布:淘宝内裤男模左肩纹身 编辑:程序博客网 时间:2024/05/22 01:56

001创建数据库

#% text_encoding = cp936
_package user
## Filename:  create_database.magik

#########################          
# Start of Program List # 
#########################

#!global_auto_declare?! << _true
$
# 加载地图投影坐标系
sw_module_manager.load_module(:map_projections_catalogue)
$

_block
 # 设置工程目录
 #_local project_path << "d:\gis_refinery"
 _local project_path << "d:\gis_telecom"
 _local gis_project_path << system.getenv("gis_project_path").default(project_path)
 #_local gis_project_path << system.getenv("gis_project_path1").default("d:\gis_refinery\ds\ds_landbase")
 _local db_path << system.pathname_down(gis_project_path,"ds")
 
 _if system.file_exists?(db_path) _is _false
 _then
  system.mkdir(db_path)
 _endif 

 create_database(db_path,
   :universes, 2**3,
   :units,:cm,
   :system64?,_true,
   :default_universe, {"gis", 1, 8},
   :default_world, {"gis", "world",
      :world_bounds,
      bounding_box.new(0,0,2000000000,2000000000),
      :world_used_bounds,
      bounding_box.new(0,0,2000000000,2000000000),
      :units, :cm}
 )
  
 open_database(db_path)
 _local v << gis_program_manager.cached_dataset(:gis)
 v.switch(:write)
 
 v.create_coordinate_systems()

 v.world.set_coordinate_system_by_name(:world_miller_wgs84_cm)
 v.commit()
 quit()
 
_endblock


!global_auto_declare?! << _maybe
$

#########################
#  End of Program List  #
#########################

 

002建立数据文件目录

#% text_encoding = cp936
_package user


## Filename:  create_ds_directory.magik

#########################          
# Start of Program List # 
#########################

#!global_auto_declare?! << _true
$

_block
 # 使用前请设置ds文件目录
 # 设置工程目录
 #_local project_path << "d:\gis_refinery"
 _local project_path << "d:\gis_telecom"
 _local gis_project_path << system.getenv("gis_project_path").default(project_path)
 _local db_path << system.pathname_down(gis_project_path,"ds")
 
 _if system.file_exists?(db_path) _is _false
 _then
  write("目录:" + db_path + "不存在")
  _return
 _endif

 #设置需要建立的ds目录
 _local admin_path << "ds_admin"
 _local case_path << "ds_case"
 
 #_local ds_path << "ds_refinery"
 _local ds_path << "ds_telecom"

 _local new_admin_path << db_path + "/" + admin_path
 _local new_case_path << db_path + "/" + case_path
 _local new_ds_path << db_path + "/" + ds_path

 _local ace_file << "ace.ds"
 _local style_file << "style.ds"
 _local scrapbook_file << "scrapbook.ds"
 _local scratch_file << "scratch.ds"
 _local case_file << "case.ds"
 _local case_dd_file << "case_dd.ds"
 _local rwo_file << "rwo.ds"
 _local gdb_file << "gdb.ds"
 _local raster_file << "raster.ds"
 _local dd_file << "dd.ds"
 _local ds_extension_file << "dd_extension.ds"

 system.mkdir(new_admin_path)
 system.mkdir(new_case_path)
 system.mkdir(new_ds_path)

 system.file_copy(db_path + "/" + ace_file, new_admin_path + "/" + ace_file )
 system.file_copy(db_path + "/" + style_file, new_admin_path + "/" + style_file)
 system.file_copy(db_path + "/" + scrapbook_file, new_admin_path + "/" + scrapbook_file)
 system.file_copy(db_path + "/" + scratch_file, new_admin_path + "/" + scratch_file)

 system.file_copy(db_path + "/" + case_file, new_case_path + "/" + case_file )
 system.file_copy(db_path + "/" + case_dd_file, new_case_path + "/" + case_dd_file )

 system.file_copy(db_path + "/" + rwo_file, new_ds_path + "/" + rwo_file )
 system.file_copy(db_path + "/" + gdb_file, new_ds_path + "/" + gdb_file )
 system.file_copy(db_path + "/" + raster_file, new_ds_path + "/" + raster_file )
 system.file_copy(db_path + "/" + dd_file, new_ds_path + "/" + dd_file )
 system.file_copy(db_path + "/" + ds_extension_file, new_ds_path + "/" + ds_extension_file )

 _local ace_file_path << db_path + "\" + ace_file
 _local style_file_path << db_path + "\" + style_file
 _local scrapbook_file_path << db_path + "\" + scrapbook_file
 _local scratch_file_path << db_path + "\" + scratch_file
 _local case_file_path << db_path + "\" + case_file
 _local case_dd_file_path << db_path + "\" + case_dd_file
 _local rwo_file_path << db_path + "\" + rwo_file
 _local gdb_file_path << db_path + "\" + gdb_file
 _local raster_file_path << db_path + "\" + raster_file
 _local dd_file_path << db_path + "\" + dd_file
 _local ds_extension_file_path << db_path + "\" + ds_extension_file
  
 system.do_command("del " + rwo_file_path)
 system.do_command("del " + gdb_file_path)
 system.do_command("del " + raster_file_path)
 system.do_command("del " + dd_file_path)
 system.do_command("del " + ds_extension_file_path)
 
 # manage_soc
 system.putenv("SW_SESSION_ACE_DB_DIR",new_admin_path)
 manage_soc(new_admin_path)
 # %SW_SESSION_ACE_DB_DIR%/../ds_admin
 # %SW_SESSION_ACE_DB_DIR%/../ds_case
 # %SW_SESSION_ACE_DB_DIR%/../ds_refinery
 # %SW_SESSION_ACE_DB_DIR%/../ds_telecom
 
_endblock

!global_auto_declare?! << _maybe
$

#########################
#  End of Program List  #
#########################

 

003加载文件

#% text_encoding = cp936
_package user
#########################          
# Start of Program List # 
#########################

#!global_auto_declare?! << _true
$

_block
 _local root_dir   << system.pathname_up(!compiler_file!,1)

 # Find the modules
 write(root_dir)
 load_file(root_dir + "/" + "001create_database.magik")
_endblock

!global_auto_declare?! << _maybe
$

#########################
#  End of Program List  #
#########################

004建立world type


#建立world type
v << gis_program_manager.databases[:gis]
$
#查看数据库中已经定义universe
print(v.collections[:sw_gis!world_type])
$
v.mode
$

v.switch(:write)
$

#定义数据集的universe
#Defining a universe
#gis_ds_view.define_world_type( type_name, max_no_of_worlds, _optional priority_bits )

#定义名为"internals"的universe
v.define_world_type( "internals", 2**24, 5)
$

#定义名为"schematics"的universe
v.define_world_type( "schematics", 2**24, 5)
$

v.commit()
$

005打开数据库

#% text_encoding = cp936
_package user
## Filename:  open_database.magik
#########################          
# Start of Program List # 
#########################

#!global_auto_declare?! << _true
$

_block
 _local gis_project_path << system.getenv("gis_project_path1").default("d:\gis_refinery")
 _local db_path << system.pathname_down(gis_project_path,"ds")
  
 _if db_path _is _unset
 _then
  _return
 _endif

 _if system.file_exists?(db_path) _is _false
 _then
  _return
 _endif

 _local new_admin_path << db_path + "\" + "ds_admin"
 open_database(new_admin_path)
 startup()
 
_endblock

!global_auto_declare?! << _maybe
$

#########################
#  End of Program List  #
#########################

006建立landbase数据集

#% text_encoding = cp936
_package user
#########################
# Start of Program List #
#########################

#!global_auto_declare?! << _true
$
# 加载地图投影坐标系
sw_module_manager.load_module(:map_projections_catalogue)
$
_block @creat_landbase
 # 建立landbase数据集
 # 设置工程目录
 
 #_local project_path << "d:\gis_refinery"
 _local project_path << "d:\gis_telecom"
 _local gis_project_path << system.getenv("gis_project_path").default(project_path)
 _local db_path << system.pathname_down(gis_project_path,"ds")
 
 _if system.file_exists?(db_path) _is _false
 _then
  write("目录:" + db_path + "不存在")
  _return
 _endif

 #设置需要建立的ds目录
 _local ds_path << "ds_landbase"
 _local new_ds_path << db_path + "/" + ds_path
 system.mkdir(new_ds_path)
 #建立数据集
 create_database(new_ds_path,
   :universes, 2**3,
   :units,:cm,
   :system64?,_true,
   :default_universe, {"gis", 1, 8},
   :default_world, {"gis", "world",
      :world_bounds,
      bounding_box.new(0,0,2000000000,2000000000),
      :world_used_bounds,
      bounding_box.new(0,0,2000000000,2000000000),
      :units, :cm}
 )

 open_database(new_ds_path)
 _local v << gis_program_manager.cached_dataset(:gis)
 v.switch(:write)

 #设置坐标系
 v.create_coordinate_systems()

 v.world.set_coordinate_system_by_name(:world_miller_wgs84_cm)
 v.commit()
 quit()
 
_endblock #<@label>

!global_auto_declare?! << _maybe
$

#########################
#  End of Program List  #
#########################

007批量删除ds文件

#% text_encoding = cp936
_package user
#########################
# Start of Program List #
#########################

#!global_auto_declare?! << _true
$
#删除多余的ds文件
_block

 # 设置工程目录
 
 #_local project_path << "d:\gis_refinery"
 _local project_path << "d:\gis_telecom"
 _local pathname << "ds_landbase"
 
 _local gis_project_path << system.getenv("gis_project_path").default(project_path)
 _local ds_path << system.pathname_down(gis_project_path,"ds")

 _local db_path << ds_path + "\" + pathname

 _local ace_file << "ace.ds"
 _local style_file << "style.ds"
 _local scrapbook_file << "scrapbook.ds"
 _local scratch_file << "scratch.ds"
 _local case_file << "case.ds"
 _local case_dd_file << "case_dd.ds"

 _local ace_file_path << db_path + "\" + ace_file
 _local style_file_path << db_path + "\" + style_file
 _local scrapbook_file_path << db_path + "\" + scrapbook_file
 _local scratch_file_path << db_path + "\" + scratch_file
 _local case_file_path << db_path + "\" + case_file
 _local case_dd_file_path << db_path + "\" + case_dd_file

 system.do_command("del " + ace_file_path) 
 system.do_command("del " + style_file_path)
 system.do_command("del " + scrapbook_file_path)
 system.do_command("del " + scratch_file_path)
 system.do_command("del " + case_file_path)
 system.do_command("del " + case_dd_file_path)
      
_endblock #
 

!global_auto_declare?! << _maybe
$

#########################
#  End of Program List  #
#########################

 

 

 

0 0