public static PostGISOpts fromMap(Map<?,Object> map) { PostGISOpts pgopts = new PostGISOpts(PostGIS.DB.get(map)); if (PostGIS.SCHEMA.in(map)) { pgopts.schema(PostGIS.SCHEMA.get(map)); } if (PostGIS.HOST.in(map)) { pgopts.host(PostGIS.HOST.get(map)); } if (PostGIS.PORT.in(map)) { pgopts.port(PostGIS.PORT.get(map)); } if (PostGIS.USER.in(map)) { pgopts.user(PostGIS.USER.get(map)); } if (PostGIS.PASSWD.in(map)) { pgopts.passwd(PostGIS.PASSWD.get(map)); } return pgopts; }
@Override public boolean canCreate(Map<?, Object> opts, Messages msgs) { return FILE.in(opts); }
public static CSVOpts fromMap(Map<?, Object> map) { CSVOpts csvOpts = new CSVOpts(); csvOpts.delimiter(DELIM.get(map)).header(HEADER.get(map)); Object x = X.get(map); if (x instanceof Integer) { csvOpts.xy((Integer)x, (Integer)Y.get(map)); } else { csvOpts.xy(x.toString(), Y.get(map).toString()); } return csvOpts; }
@Override public boolean canOpen(Map<?, Object> opts, Messages msgs) { if (!DB.in(opts)) { Messages.of(msgs).report("No " + DB + " option specified"); return false; } return true; }
@Override protected boolean canOpen(File file, Map<?, Object> opts, Messages msgs) { msgs = Messages.of(msgs); if (DRIVER.in(opts)) { String drvName = DRIVER.get(opts); Driver drv = ogr.GetDriverByName(drvName); if (drv == null) { msgs.report("Unknown driver: " + drvName); return false; } try { DataSource data = drv.Open(file.getAbsolutePath()); if (data == null) { msgs.report("Driver: " + drvName + " unable to open file: " + file); return false; } } catch(Exception e) { msgs.report(e); return false; } } return true; }
@Override public GeobufDataset create(Map<?, Object> opts, Schema schema) throws IOException { return new GeobufDataset(FILE.get(opts)); } }
@Override public boolean canOpen(Map<?, Object> opts, Messages msgs) { if (!DB.in(opts)) { Messages.of(msgs).report("No " + DB + " option specified"); return false; } return true; }
@Override protected OGRWorkspace open(File file, Map<?, Object> opts) throws IOException { // was driver explicitly specified if (DRIVER.in(opts)) { Driver drv = ogr.GetDriverByName(DRIVER.get(opts)); return new OGRWorkspace(file, new OGR(drv)); } DataSource ds = ogr.OpenShared(file.getAbsolutePath()); if (ds == null) { throw new IOException("Unable to open file: " + file); } try { return new OGRWorkspace(file, new OGR(ds.GetDriver())); } finally { ds.delete(); } }
public static MBTilesOpts fromMap(Map<?,Object> map) { return new MBTilesOpts(FILE.get(map)); }