Package org.geotools.data.shapefile.dbf

Examples of org.geotools.data.shapefile.dbf.DbaseFileWriter$FieldFormatter


        }
        header.setNumRecords(values.length);
        FileOutputStream fos = new FileOutputStream(tmp);
        WritableByteChannel channel = fos.getChannel();
        tmp.deleteOnExit();
        DbaseFileWriter writer = new DbaseFileWriter(header, channel, cs, tz);
        // write records such that the i-th row has nulls in every column except the i-th column
        for (int row = 0; row < values.length; row++) {
            Object[] current = new Object[values.length];
            Arrays.fill(current, null);
            current[row] = values[row];
            writer.write(current);
        }
        writer.close();
        fos.flush();
        fos.close();
        DbaseFileReader reader = new DbaseFileReader(new FileInputStream(tmp).getChannel(), false, cs, tz);
        assertTrue("Number of records does not match", values.length == reader.getHeader().getNumRecords());
        for (int row = 0; row < values.length; row++) {
View Full Code Here


        FileChannel shxChannel = storageFiles.get(SHX).getWriteChannel();
        shpWriter = new ShapefileWriter(shpChannel, shxChannel);

        dbfHeader = ShapefileDataStore.createDbaseHeader(featureType);
        dbfChannel = storageFiles.get(DBF).getWriteChannel();
        dbfWriter = new DbaseFileWriter(dbfHeader, dbfChannel, dbfCharset, dbfTimeZone);

        // don't try to read a shx file we're writing to in parallel
        featureReader.disableShxUsage();
        guessShapeType = !featureReader.hasNext();
        shapeType = featureReader.getShapeType();
View Full Code Here

        header.setNumRecords(20);
        File f = new File(System.getProperty("java.io.tmpdir"),
                "scratchDBF.dbf");
        f.deleteOnExit();
        FileOutputStream fout = new FileOutputStream(f);
        DbaseFileWriter dbf = new DbaseFileWriter(header, fout.getChannel(), Charset.defaultCharset());
        for (int i = 0; i < header.getNumRecords(); i++) {
            dbf.write(new Object[6]);
        }
        dbf.close();
        ShpFiles tempShpFiles = new ShpFiles(f);
        DbaseFileReader r = new DbaseFileReader(tempShpFiles, false,
                ShapefileDataStore.DEFAULT_STRING_CHARSET);
        int cnt = 0;
        while (r.hasNext()) {
View Full Code Here

TOP

Related Classes of org.geotools.data.shapefile.dbf.DbaseFileWriter$FieldFormatter

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.