当前位置: 首页>>代码示例>>Java>>正文


Java SFSUtilities类代码示例

本文整理汇总了Java中org.h2gis.utilities.SFSUtilities的典型用法代码示例。如果您正苦于以下问题:Java SFSUtilities类的具体用法?Java SFSUtilities怎么用?Java SFSUtilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SFSUtilities类属于org.h2gis.utilities包,在下文中一共展示了SFSUtilities类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import org.h2gis.utilities.SFSUtilities; //导入依赖的package包/类
public boolean open( String dbPath ) throws Exception {
    h2Db.setCredentials(user, password);

    if (dbPath != null && dbPath.endsWith(EDb.H2GIS.getExtension())) {
        dbPath = dbPath.substring(0, dbPath.length() - (EDb.H2GIS.getExtension().length() + 1));
    }
    boolean dbExists = h2Db.open(dbPath);
    if (dbExists) {
        wasInitialized = true;
    }

    jdbcConn = SFSUtilities.wrapConnection(h2Db.getJdbcConnection());
    if (!dbExists)
        initSpatialMetadata(null);

    this.mDbPath = h2Db.getDatabasePath();
    mConn = h2Db.getConnection();
    if (mPrintInfos) {
        if (!wasInitialized) {
            initSpatialMetadata(null);
        }
        String[] dbInfo = getDbInfo();
        Logger.INSTANCE.insertDebug(null, "H2GIS Version: " + dbInfo[1]);
    }
    return dbExists;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:27,代码来源:H2GisDb.java

示例2: run

import org.h2gis.utilities.SFSUtilities; //导入依赖的package包/类
@Override
public void run() {
    //Creates the session workspace
    File workspaceFolder = new File("workspace", token.toString());
    workspaceFolder.mkdirs();
    propertyMap.put(ServiceFactory.WORKSPACE_FOLDER_PROP, workspaceFolder);

    //Creates the session ExecutorService
    ExecutorService executorService = Executors.newFixedThreadPool(3);
    propertyMap.put(ServiceFactory.EXECUTOR_SERVICE_PROP, executorService);

    //Creates the session DataSource
    DataSource dataSource = null;
    try {
        dataSource = SFSUtilities.wrapSpatialDataSource(H2GISDBFactory.createDataSource("/../../../workspace/"+this.token+"/h2_db", true));
    } catch (SQLException e) {
        LOGGER.error("Unable to create the database : \n"+e.getMessage());
    }
    LOGGER.info("Session database started.");
    propertyMap.put(ServiceFactory.DATA_SOURCE_PROP, dataSource);


    //Sets the session with the options
    List<Service> serviceList = new ArrayList<>();
    for(ServiceFactory factory : serviceFactoryList) {
        Service service = factory.createService(propertyMap);
        serviceList.add(service);
        LOGGER.info("Service "+service.getClass().getSimpleName()+" started.");
    }
    propertyMap.put(Session.SERVICE_LIST, serviceList);

    session.setProperties(propertyMap);
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:34,代码来源:SessionInitializer.java

示例3: getDatabaseContent

import org.h2gis.utilities.SFSUtilities; //导入依赖的package包/类
/**
 * Returns the DatabaseContent object which contains the representation of the Database.
 * @return The DatabaseContent object.
 */
public DatabaseContent getDatabaseContent(){
    DatabaseContent dbContent = new DatabaseContent();
    try(Connection connection = ds.getConnection()) {
        for(String tableName : JDBCUtilities.getTableNames(connection.getMetaData(), null, null, null, new String[]{"TABLE","LINKED TABLE","VIEW","EXTERNAL","UIodfsghjmodfhjgodujhfg"})){
            DatabaseTable dbTable = new DatabaseTable(TableLocation.parse(tableName));
            //Get the list of the columns of a table
            ResultSet rs1 = connection.createStatement().executeQuery(String.format("select * from %s limit 1",
                    dbTable.getName()));
            ResultSetMetaData metaData = rs1.getMetaData();
            //If the column isn't a geometry, add it to the map
            for(int i=1; i<=metaData.getColumnCount(); i++){
                if(!metaData.getColumnTypeName(i).equalsIgnoreCase("GEOMETRY")){
                    dbTable.addField(metaData.getColumnLabel(i), metaData.getColumnTypeName(i));
                }
            }
            //Once the non geometric columns are get, do the same with the geometric one.
            Statement statement = connection.createStatement();
            String query = String.format("SELECT * FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME LIKE '%s';",
                    TableLocation.parse(dbTable.getName()).getTable());
            ResultSet rs = statement.executeQuery(query);
            while (rs.next()) {
                dbTable.addField(rs.getString(4), SFSUtilities.getGeometryTypeNameFromCode(rs.getInt(6)));
            }
            dbContent.addTable(dbTable);
        }
    } catch (SQLException e) {
        LOGGER.error("Unable to get the database information.\nCause : "+e.getMessage());
    }
    return dbContent;
}
 
开发者ID:totone56,项目名称:orbis-lps2ima-dev,代码行数:35,代码来源:Session.java

示例4: main

import org.h2gis.utilities.SFSUtilities; //导入依赖的package包/类
public static void main (String[] args) {
    try {
        // Use H2 DataSourceFactory
        DataSourceFactory dataSourceFactory = new OsgiDataSourceFactory(org.h2.Driver.load());
        // Set properties for in-memory connection
        Properties properties = JDBCUrlParser.parse("jdbc:h2:/"+new File("sample_db").getAbsolutePath());
        // Create instance of data manager.
        DataManager dataManager = new DataManagerImpl(SFSUtilities.wrapSpatialDataSource(
                dataSourceFactory.createDataSource(properties)));
        // Init spatial functions
        try(Connection connection = dataManager.getDataSource().getConnection();
                Statement st = connection.createStatement()) {
            // Import spatial functions, domains and drivers
            // If you are using a file database, you have to do only that once.
            st.execute("DROP TABLE IF EXISTS landcover2000");
            CreateSpatialExtension.initSpatialExtension(connection);
            // Read OWS context file
            MapContext mc = new OwsMapContext(dataManager);
            String owsFile = "landcover2000.ows";
            // Set where to fetch resources
            mc.setLocation(Main.class.getResource("landcover2000.ows").toURI());
            mc.read(Main.class.getResourceAsStream(owsFile));
            // Read the file
            // Open it (it will link the database with the shape file)
            mc.open(new NullProgressMonitor());
            // Render it in buffered image
            MapImageWriter mapImageWriter = new MapImageWriter(mc.getLayerModel());
            FileOutputStream out = new FileOutputStream(new File("landcover2000.png").getAbsoluteFile());
            mapImageWriter.setFormat(MapImageWriter.Format.PNG);
            mapImageWriter.write(out, new NullProgressMonitor());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:orbisgis,项目名称:orbisgis-samples,代码行数:36,代码来源:Main.java


注:本文中的org.h2gis.utilities.SFSUtilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。