When reading OSM files using GDAL, the fields that are read are defined in osmconf.ini, and if I want that certain tags don't appear within the other_tags then I need to add them to the attributes value in the corresponding sections.
This works fine, but is not really portable, so my questions is, is there a ways to define the settings saved in osmconf.ini in a portable way per project?
This is possible using the CPLSetConfigOption function, and store the config file in current working directory:
CPLSetConfigOption("OSM_CONFIG_FILE", "osmconf.ini");
Related
I am currently using Bruno Paz's extension File Templates to create some file templates...lol. The issue is I am having trouble locating where the templates are stored once they are created. I want to find where and how they are stored so I can hard code some templates in. That way users of my version of the extension will have premade templates they can immediately access instead of having to create them first. The readme indicates that the Templates should be stored as follows for windows:
C:\Users\User\AppData\Roaming\Code\User\FileTemplates
However, that path does not exist for me. The readme also states the following (I could use this a possible work around):
However, you can change the default location by adding the following to your user or workspace settings:
"fileTemplates.templates_dir": "path/to/my/templates"
However, Im unaware of what workspace settings are in VS Code.
I'm writing a c++ code using qt and need an editable config file for my user to change some settings. In order to provide him some additional information I would like to add comments to my config file, however I cant find a way to mark them as comments.
I am using QSettings, my file is a .flt file. The usual '#' unfortunately does not seem to work with QSettings.
when using setting files in Qt and the QSettings class, you don't use the "usual"
#
for defining a comment, but the
;
instead...
so:
[abc]
key=val
;this is a comment in the QSettings
flag=true
QSetting's INI file format uses MS Windows file format, which is
a) hierarchical and uses brackets [] for section names
b) uses ; to designate comment lines.
Note, thr default engine of QSetting would wipe any comments, because the whole mechanism is just serialization of name-value pairs from file and to file. To avoid that, a custom reader-writer class should be devised which would read and preserve comments somehow. QSettings supports custom formats by offering interface for read and write functions.
I am using Django and All-auth. I want to restrict users to take certain usernames. I know that it is done through writing the following in settings.py.
ACCOUNT_USERNAME_BLACKLIST (=[])
But I want to take this list from a .txt file. Should I read the .txt file in my settings.py and then populate the ACCOUNT_USERNAME_BLACKLIST (=[]) list? Or there is some other way that is more reasonable and considered as a best practice?
Yes. You can just read in the text file in your settings file.
Its a common practice done where people will often load in a json file that contains values for a load of different settings that may change depending on environment.
I am interested in creating a config.cfc which I want to use in differenct components.
in PHP one can create a config.php file which simply return an array. and in other php files this can be included like
use config.php
Can I simple include a .cfm file in any .cfc component? of a config.cfc which simply returns a STRUCT?
I'm not sure how to answer your question because I don't fully understand what you're trying to accomplish. In one sentence you need to return an array and in another sentence you need to return a struct. If you're looking to create a config.cfc your method(s) can return either datatype (array or struct).
To answer your other question, yes you can include a .cfm file within a .cfc. I've done it in the past, although it's not best practice.
What I would suggest instead, in your config.cfc, create any needed methods then use CreateObject() in your calling .cfm or .cfc for usage.
I have seen several projects that use a .cfm file as a config file and it sets a Coldfusion struct variable with setting values. Using cfinclude will then load the file and set a config variable (usually a struct). It could just as easily set an array although I think structs would be more flexible. There is usually logic in the code to cfinclude the config.cfm file once and store the setting in the application scope.
Another option is to use a .json file that contains the same kind of thing but in JSON format. Here's an example of an open source project that does that:
https://github.com/tonyjunkes/CFFormProtect-Revamp/blob/master/cfformprotect/config.json
The controlling code reads the file and uses deserializeJSON() to convert it to a ColdFusion struct. Since it is open source you could download this project and see exactly how it is working.
Yes, you can cfinclude a .cfm from a .cfc file.
I have a configuration file system written in C++ which uses the yaml-cpp library to parse and write to YAML files. I have this as part of my static library.
I would like the ability to return a default value for a field that is requested by a user of the library (calling from their code), but which has not been defined in the user's YAML file.
For example say the user wants to use the field foo from their custom config.yaml file:
int bar = config_reader.read<int>( "config.yaml", "foo" );
If they have foo: 10 in their config.yaml then bar will be set to 10. However I would also like to provide a default value (for example 4) in the case where foo is omitted from config.yaml.
There are two possibilities I have thought of:
Have a set of static maps between field names and default values in a cpp file which gets compiled into the static library, however I will need to have different maps for different types and I feel this could get messy with type checking and maybe requiring template specialization methods.
Have a YAML file which contains all of the default values for expected fields, which the configuration system falls back on if it cannot find the field in the user's config file. I think this would be the preferred solution for me, but I cannot think of a neat way of packaging this YAML file. I would rather the user didn't have to copy or point to this file each time they set up a new project linking the static library.
I would provide the defaults in a YAML file in a global (i.e. non-user specific place) and allow to override the values with user-specific ones.
Consider just throwing an error if the global defaults are missing an entry, this will not happen by accident.
The global defaults you can put in /etc/default/YOUBLIBNAME.yaml. The user's configuration nowadays mostly follows the XDG base directory specification. For that use $XDG_CONFIG_HOME/YOURLIBNAME/config.yaml if XDG_CONFIG_HOME is set in the environment, if not set use $HOME/.config/YOURLIBNAME/config.yaml.
If your library has to work under Windows, I would put the user specific data under %APPDATA% in a subdir YOURBLINAME.