<commit_before>package mil.nga.geopackage.features;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import mil.nga.geopackage.GeoPackage;
import mil.nga.geopackage.features.columns.GeometryColumns;
import mil.nga.geopackage.features.user.FeatureColumn;
import mil.nga.geopackage.features.user.FeatureDao;
import mil.nga.geopackage.features.user.FeatureRow;
import mil.nga.sf.Geometry;

/**
 * OGC API Feature Generator
 *
 * @author osbornb
 */
public class OAPIFeatureGenerator extends OAPIFeatureCoreGenerator {

    /**
     * Feature DAO
     */
    protected FeatureDao featureDao;

    /**
     * Constructor
     *
     * @param geoPackage GeoPackage
     * @param tableName  table name
     * @param server     server url
     * @param name       collection identifier
     */
    public OAPIFeatureGenerator(GeoPackage geoPackage, String tableName,
                                String server, String name) {
        super(geoPackage, tableName, server, name);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GeoPackage getGeoPackage() {
        return (GeoPackage) geoPackage;
    }

    /**
     * Get the feature DAO
     *
     * @return feature DAO
     */
    public FeatureDao getFeatureDao() {
        return featureDao;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void addColumn(FeatureColumn featureColumn) {
        featureDao.addColumn(featureColumn);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void createFeature(Geometry geometry,
                                 Map<String, Object> properties) throws SQLException {

        if (srs == null) {
            createSrs();
        }

        if (featureDao == null) {
            GeometryColumns geometryColumns = createTable(properties);
            featureDao = getGeoPackage().getFeatureDao(geometryColumns);
        }

        Map<String, Object> values = new HashMap<>();

        for (Entry<String, Object> property : properties.entrySet()) {
            String column = property.getKey();
            Object value = getValue(column, property.getValue());
            values.put(column, value);
        }

        FeatureRow featureRow = featureDao.newRow();

        featureRow.setGeometry(createGeometryData(geometry));
        for (Entry<String, Object> value : values.entrySet()) {
            featureRow.setValue(value.getKey(), value.getValue());
        }<commit_msg>OGC API feature generator updates using common implementation<commit_after>package mil.nga.geopackage.features;

import java.util.Map;
import java.util.Map.Entry;

import mil.nga.geopackage.GeoPackage;
import mil.nga.geopackage.features.user.FeatureColumn;
import mil.nga.geopackage.features.user.FeatureDao;
import mil.nga.geopackage.features.user.FeatureRow;
import mil.nga.sf.Geometry;

/**
 * OGC API Feature Generator
 *
 * @author osbornb
 */
public class OAPIFeatureGenerator extends OAPIFeatureCoreGenerator {

    /**
     * Feature DAO
     */
    protected FeatureDao featureDao;

    /**
     * Constructor
     *
     * @param geoPackage GeoPackage
     * @param tableName  table name
     * @param server     server url
     * @param name       collection identifier
     */
    public OAPIFeatureGenerator(GeoPackage geoPackage, String tableName,
                                String server, String name) {
        super(geoPackage, tableName, server, name);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GeoPackage getGeoPackage() {
        return (GeoPackage) geoPackage;
    }

    /**
     * Get the feature DAO
     *
     * @return feature DAO
     */
    public FeatureDao getFeatureDao() {
        return featureDao;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void addColumn(FeatureColumn featureColumn) {
        featureDao.addColumn(featureColumn);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void initializeTable() {
        featureDao = getGeoPackage().getFeatureDao(geometryColumns);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void saveFeature(Geometry geometry, Map<String, Object> values) {

        FeatureRow featureRow = featureDao.newRow();

        featureRow.setGeometry(createGeometryData(geometry));
        for (Entry<String, Object> value : values.entrySet()) {
            featureRow.setValue(value.getKey(), value.getValue());
        }
{'fraction_non_alphanumeric': 0.10379464285714286, 'fraction_numerical': 0.0, 'mean_word_length': 2.438986953184958, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3637211', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1262, 'n_words': 269}