Beispiel #1
0
static json_object* json_object_new_coord(double dfVal, int nCoordPrecision, int nSignificantFigures)
{
    // If coordinate precision is specified, or significant figures is not
    // then use the '%f' formatting
    if( nCoordPrecision >= 0 || nSignificantFigures < 0 )
        return json_object_new_double_with_precision(dfVal, nCoordPrecision);
    return json_object_new_double_with_significant_figures(dfVal, nSignificantFigures);
}
Beispiel #2
0
CPL_C_END

/**
 * Add new key - value pair to json object.
 * @param osName  Key name.
 * @param dfValue Double value.
 *
 * @since GDAL 2.3
 */
void CPLJSONObject::Add(const std::string &osName, double dfValue)
{
    std::string objectName;
    CPLJSONObject object = GetObjectByPath( osName, objectName );
    if( object.IsValid() &&
        json_object_get_type(TO_JSONOBJ(object.m_poJsonObject)) ==
            json_type_object )
    {
        json_object *poVal = json_object_new_double_with_significant_figures( dfValue, -1 );
        json_object_object_add( TO_JSONOBJ(object.GetInternalHandle()),
                                           objectName.c_str(), poVal );
    }
}