Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * h2spatial is a library that brings spatial support to the H2 Java database.
  *
  * h2spatial is distributed under GPL 3 license. It is produced by the "Atelier SIG"
  * team of the IRSTV Institute <http://www.irstv.fr/> CNRS FR 2488.
  *
  * Copyright (C) 2007-2014 IRSTV (FR CNRS 2488)
  *
  * h2patial is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * h2spatial is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * h2spatial. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, please consult: <http://www.orbisgis.org/>
 * or contact directly:
 * info_at_ orbisgis.org
 */
package org.h2gis.drivers.shp;
SQL Function to copy Shape File data into a Table.

Author(s):
Nicolas Fortin
public class SHPRead  extends AbstractFunction implements ScalarFunction {
    public SHPRead() {
        addProperty("Read a shape file and copy the content in the specified table.");
    }
    @Override
    public String getJavaStaticMethod() {
        return "readShape";
    }

    
Copy data from Shape File into a new table in specified connection.

Parameters:
connection Active connection
tableReference [[catalog.]schema.]table reference
fileName File path of the SHP file or URI
forceEncoding Use this encoding instead of DBF file header encoding property.
    public static void readShape(Connection connectionString fileNameString tableReference,String forceEncodingthrows IOExceptionSQLException {
        File file = URIUtility.fileFromString(fileName);
        if(!file.exists()) {
            throw new FileNotFoundException("The following file does not exists:\n"+fileName);
        }
        SHPDriverFunction shpDriverFunction = new SHPDriverFunction();
        shpDriverFunction.importFile(connection, TableLocation.parse(tableReferencetrue).toString(true),
                filenew EmptyProgressVisitor(), forceEncoding);
    }

    
Copy data from Shape File into a new table in specified connection.

Parameters:
connection Active connection
tableReference [[catalog.]schema.]table reference
fileName File path of the SHP file or URI
    public static void readShape(Connection connectionString fileNameString tableReferencethrows IOExceptionSQLException {
        readShape(connectionfileNametableReferencenull);
    }

    
Copy data from Shape File into a new table in specified connection. The newly created table is given the same name as the filename without the ".shp" extension. If such a table already exists, an exception is thrown.

Parameters:
connection Active connection
fileName File path of the SHP file or URI
    public static void readShape(Connection connectionString fileNamethrows IOExceptionSQLException {
        final String name = URIUtility.fileFromString(fileName).getName();
        readShape(connectionfileNamename.substring(0, name.lastIndexOf(".")).toUpperCase());
    }
New to GrepCode? Check out our FAQ X