Package org.bridj

Examples of org.bridj.Pointer


     * @param layer
     * @return
     * @throws IOException
     */
    private CoordinateReferenceSystem getCRS(Pointer layer) throws IOException {
        Pointer spatialReference = null;
        CoordinateReferenceSystem crs = null;
        try {
            spatialReference = OGR_L_GetSpatialRef(layer);
            if (spatialReference == null) {
                return null;
View Full Code Here


        boolean changed = !live.equals(original);
        if (!changed && original != null) {
            // nothing to do, just skip
        } else if (original != null) {
            // not equals, we're updating an existing one
            Pointer ogrFeature = mapper.convertGTFeature(layerDefinition, live);
            checkError(OGR_L_SetFeature(layer, ogrFeature));
        } else {
            Pointer ogrFeature = mapper.convertGTFeature(layerDefinition, live);
            checkError(OGR_L_CreateFeature(layer, ogrFeature));
            String geotoolsId = mapper.convertOGRFID(featureType, ogrFeature);
      ((FeatureIdImpl) live.getIdentifier()).setID(geotoolsId);
            OGR_F_Destroy(ogrFeature);
        }
View Full Code Here

        boolean changed = !live.equals(original);
        if (!changed && original != null) {
            // nothing to do, just skip
        } else if (original != null) {
            // not equals, we're updating an existing one
            Pointer ogrFeature = mapper.convertGTFeature(layerDefinition, live);
            checkError(OGR_L_SetFeature(layer, ogrFeature));
        } else {
            Pointer ogrFeature = mapper.convertGTFeature(layerDefinition, live);
            checkError(OGR_L_CreateFeature(layer, ogrFeature));
            String geotoolsId = mapper.convertOGRFID(featureType, ogrFeature);
      ((FeatureIdImpl) live.getIdentifier()).setID(geotoolsId);
            OGR_F_Destroy(ogrFeature);
        }
View Full Code Here

        }
      } catch(Exception e) {
        HAS_L_GETNAME = false;
      }
      if(namePtr == null) {
        Pointer layerDefinition = OGR_L_GetLayerDefn(layer);
      namePtr = OGR_FD_GetName(layerDefinition);
      }
    return getCString(namePtr);
    }
View Full Code Here

   
  }

  private static void appendFeatures(final String format, final String fileName, final String layerName) {
   
        Pointer driver = OgrLibrary.OGRGetDriverByName(pointerToCString(format));
        Pointer<?> pDataSource = OgrLibrary.OGR_Dr_Open(driver, pointerToCString(fileName), 1); // with 0-read work
      
        assert pDataSource != null;
        Pointer<?> pLayer = OgrLibrary.OGR_DS_GetLayerByName(pDataSource, pointerToCString(layerName));
       
View Full Code Here

        this.builder = new SimpleFeatureBuilder(schema);
        this.geomMapper = new GeometryMapper.WKB(geomFactory);
        this.geomFactory = geomFactory;
       
        attributeIndexes = new HashMap<String, Integer>();
        Pointer layerDefinition = OGR_L_GetLayerDefn(layer);
        int size = OGR_FD_GetFieldCount(layerDefinition);
        for(int i = 0; i < size; i++) {
            Pointer  field = OGR_FD_GetFieldDefn(layerDefinition, i);
            Pointer<Byte> namePtr = OGR_Fld_GetNameRef(field);
            String name = namePtr.getCString();
            if(targetSchema.getDescriptor(name) != null) {
                attributeIndexes.put(name, i);
            }
View Full Code Here

     * @throws DataSourceException
     */
    Pointer convertGTFeature(Pointer featureDefinition, SimpleFeature feature)
            throws IOException {
        // create a new empty OGR feature
        Pointer ogrFeature = OGR_F_Create(featureDefinition);

        // go thru GeoTools feature attributes, and convert
        SimpleFeatureType schema = feature.getFeatureType();
        for (int i = 0, j = 0; i < schema.getAttributeCount(); i++) {
            Object attribute = feature.getAttribute(i);
            if (attribute instanceof Geometry) {
                // using setGeoemtryDirectly the feature becomes the owner of the generated
                // OGR geometry and we don't have to .delete() it (it's faster, too)
                Pointer geometry = geomMapper.parseGTGeometry((Geometry) attribute);
                OGR_F_SetGeometryDirectly(ogrFeature, geometry);
            } else {
                setFieldValue(featureDefinition, ogrFeature, j, attribute);
                j++;
            }
View Full Code Here

    static void setFieldValue(Pointer featureDefinition, Pointer ogrFeature, int fieldIdx,
            Object value) throws IOException {
         if (value == null) {
            OGR_F_UnsetField(ogrFeature, fieldIdx);
        } else {
            Pointer fieldDefinition = OGR_FD_GetFieldDefn(featureDefinition, fieldIdx);
            long ogrType = OGR_Fld_GetType(fieldDefinition).value();
            if (ogrType == OGRFieldType.OFTInteger.value()) {
                OGR_F_SetFieldInteger(ogrFeature, fieldIdx, ((Number) value).intValue());
            } else if (ogrType == OGRFieldType.OFTReal.value()) {
                OGR_F_SetFieldDouble(ogrFeature, fieldIdx, ((Number) value).doubleValue());
View Full Code Here

        this.ogrDriver = ogrDriver;
    }

    @Override
    protected List<Name> createTypeNames() throws IOException {
        Pointer dataSource = null;
        Pointer layer = null;
        try {
            dataSource = openOGRDataSource(false);

            List<Name> result = new ArrayList<Name>();
            int count = OGR_DS_GetLayerCount(dataSource);
View Full Code Here

            OGRUtils.releaseLayer(layer);
        }
    }

    Pointer openOGRDataSource(boolean update) throws IOException {
        Pointer ds = null;
        Pointer<Byte> sourcePtr = pointerToCString(ogrSourceName);
        int mode = update ? 1 : 0;
        if (ogrDriver != null) {
         
            Pointer driver = OGRGetDriverByName(pointerToCString(ogrDriver));
            if (driver == null) {
                throw new IOException("Could not find a driver named " + driver);
            }
            ds = OGR_Dr_Open(driver, sourcePtr, mode);
            if (ds == null) {
View Full Code Here

TOP

Related Classes of org.bridj.Pointer

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.