Package org.geotools.data

Examples of org.geotools.data.DataStore


  public static DataStore getDataStoreFromFile(File file, String charsetName)
      throws Exception {
    // For vector data files
    HashMap<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("url", file.toURI().toURL());
    DataStore ds = DataStoreFinder.getDataStore(params);

    // Shapefile DBF's charset
    if (ds instanceof ShapefileDataStore && charsetName != null) {
      ShapefileDataStore shpDs = (ShapefileDataStore) ds;
      try {
View Full Code Here


    }
    URL endPoint = new URL(getCapabilities);
    HashMap<String, Serializable> params = new HashMap<String, Serializable>();
    params.put(WFSDataStoreFactory.URL.key, endPoint);
    WFSDataStoreFactory dsFactory = new WFSDataStoreFactory();
    DataStore ds = dsFactory.createDataStore(params);
    return ds;
  }
View Full Code Here

    params.put(PostgisDataStoreFactory.USER.key, user);
    params.put(PostgisDataStoreFactory.PASSWD.key, passwd);
    params.put(PostgisDataStoreFactory.DATABASE.key, database);
    params.put(PostgisDataStoreFactory.SCHEMA.key, schema);
    PostgisDataStoreFactory dsFactory = new PostgisDataStoreFactory();
    DataStore ds = dsFactory.createDataStore(params);
    return ds;
  }
View Full Code Here

    params.put(MySQLDataStoreFactory.PORT.key, port);
    params.put(MySQLDataStoreFactory.USER.key, user);
    params.put(MySQLDataStoreFactory.PASSWD.key, passwd);
    params.put(MySQLDataStoreFactory.DATABASE.key, database);
    MySQLDataStoreFactory dsFactory = new MySQLDataStoreFactory();
    DataStore ds = dsFactory.createDataStore(params);
    return ds;
  }
View Full Code Here

    params.put(ArcSDEDataStoreFactory.PORT_PARAM.key, port);
    params.put(ArcSDEDataStoreFactory.INSTANCE_PARAM.key, instance);
    params.put(ArcSDEDataStoreFactory.USER_PARAM.key, user);
    params.put(ArcSDEDataStoreFactory.PASSWORD_PARAM.key, passwd);
    ArcSDEDataStoreFactory dsFactory = new ArcSDEDataStoreFactory();
    DataStore ds = dsFactory.createDataStore(params);
    return ds;
  }
View Full Code Here

    params.put("port", port);
    params.put("user", user);
    params.put("passwd", passwd);
    params.put("instance", instance);
    OracleDataStoreFactory dsFactory = new OracleDataStoreFactory();
    DataStore ds = dsFactory.createDataStore(params);
    return ds;
  }
View Full Code Here

  }

  private void jButtonDataSourceTestActionPerformed(ActionEvent evt) {
    String tabName = jTabbedPaneDataSource.getSelectedComponent().getName();
    boolean succeeed = false;
    DataStore ds = null;
    try {
      FeatureSource<SimpleFeatureType, SimpleFeature> fs = null;
      String typeName = null;
      if (tabName.equals(this.jPanelFile.getName())) {
        ds = this.getSelectedDataStore(jPanelFile.getName());
        if (ds == null) {
          String filePath = jTextFieldFilePath.getText();
          String realPath = PathUtil.fakePathToReal(filePath);
          File file = new File(filePath);
          if (!file.exists()) {
            MapToolApp app = (MapToolApp) this.getParent();
            String mapDescFilePath = app.getMapDescFilePath();
            File mapDescFile = new File(mapDescFilePath);
            String dir = mapDescFile.getParentFile()
                .getAbsolutePath();
            String path = dir + File.separator + realPath;
            file = new File(path);
          }
          if (GridCoverage2DReaderFactory
              .getGridCoverage2DReaderFromFile(file) != null) {
            succeeed = true;
          }
        } else {
          if (ds.getTypeNames().length > 0) {
            typeName = ds.getTypeNames()[0];
            fs = ds.getFeatureSource(typeName);
            succeeed = true;
          }
        }
      } else {
        ds = this.getSelectedDataStore(tabName);
        typeName = this.getSelectedTypeName(tabName);
        fs = ds.getFeatureSource(typeName);
        if (fs != null) {
          succeeed = true;
        }
      }

      if (jTextFieldName.getText().length() <= 0 && typeName != null) {
        jTextFieldName.setText(typeName);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      if (ds != null) {
        ds.dispose();
      }
      if (succeeed) {
        JOptionPane.showMessageDialog(this, "Succeed!");
      } else {
        JOptionPane.showMessageDialog(this, "Failed!");
View Full Code Here

      }
    }
  }

  private DataStore getSelectedDataStore(String tabName) throws Exception {
    DataStore ds = null;

    if (tabName.equals(jPanelFile.getName())) {
      String filePath = jTextFieldFilePath.getText();
      String realPath = PathUtil.fakePathToReal(filePath);
      File file = new File(filePath);
View Full Code Here

  }

  private void jButtonWfsListLayersActionPerformed(ActionEvent evt) {
    try {
      jListWfsLayers.removeAll();
      DataStore ds = this.getSelectedDataStore(jPanelWFS.getName());
      String[] typeNames = ds.getTypeNames();
      final DefaultComboBoxModel model = new DefaultComboBoxModel(
          typeNames);
      jListWfsLayers.setModel(model);
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.getMessage());
View Full Code Here

  }

  private void jButtonPostgisListLayersActionPerformed(ActionEvent evt) {
    try {
      jListPostgisLayers.removeAll();
      DataStore ds = this.getSelectedDataStore(jPanelPostGIS.getName());
      String[] typeNames = ds.getTypeNames();
      final DefaultComboBoxModel model = new DefaultComboBoxModel(
          typeNames);
      jListPostgisLayers.setModel(model);
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.getMessage());
View Full Code Here

TOP

Related Classes of org.geotools.data.DataStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.