# mapping cameras

## todos:

- limit to 5 queries per request - split into multiple files i guess
- document the code
- document how to use
- return data in geojson, not regular json
    - https://tyrasd.github.io/osmtogeojson/
    - https://github.com/tyrasd/osmtogeojson
    - https://dev.overpass-api.de/overpass-doc/en/targets/formats.html#json 

## links
- https://overpass-turbo.eu/
- https://dabreegster.github.io/route_snapper/import.html#1/0/0
- https://umap.openstreetmap.de/en/map/new/#16/51.8751/4.5254
- https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example#List_of_streets
- https://github.com/NationalSecurityAgency/qgis-bulk-nominatim

## queries and technicalities

### how to import to qgis
once you have created the geojson files (consult the `README.md` file you can open it in qgis (Layer → Add Layer → Add Vector Layer → pick geojson data you exported)

then click on the imported layer and go to properties and make the line more visible

### missing data from api
not all streets get returned. this is because the query is only asking for objects of type `way` of specific types (primary, secondary, highway, etc. can be checked in `scripts/02-way-queries` which doesn't include i.e. bridges. This is the script that has to be tweaked to get all the data we want

to see which ones appear in a specific dataset run
```
for i in working-data/04/*; do
  echo "---------- $i -----------"
  cat "$i" | jq ".elements[] | select(.type == \"way\") | .tags.name" | sort | uniq
  echo "\n\n"
done
```
compare against amount of lines in `working-data/02/` with `wc -l` for each file and then we see which sets dont return all data then more investigation can happen and the query can be adjusted.

## checking the data from gemeenteblad for mistakes
some of the street names are misspelled. to check for that i was using the following process.
in the `source-data/by-district` directory i run a quick sed command for each neighbouhood to format data for pasting into a tool i.e. `cat 10-ijsselmonde | sed 's/, /, Rotterdam\n/g'`
this returns a list like this (abbreviated for readability):
```
Aesopusviaduct, Rotterdam
Anthony Tijkenstraat, Rotterdam
Bierens de Haanweg, Rotterdam
Bollandstraat, Rotterdam
Bolnesserkade, Rotterdam
Burgemeester Molenaarstraat, Rotterdam
Cannenburchstraat, Rotterdam
Zuidkreek.
```

then i go into https://www.mapcustomizer.com/ and use the bulk import option to mark all these streets, adding `, Rotterdam` to the last street name so it looks like this
```
Aesopusviaduct, Rotterdam
Anthony Tijkenstraat, Rotterdam
Bierens de Haanweg, Rotterdam
Bollandstraat, Rotterdam
Bolnesserkade, Rotterdam
Burgemeester Molenaarstraat, Rotterdam
Cannenburghstraat, Rotterdam
Zuidkreek, Rotterdam
```

if you try these streets 2 of them will fail (bolnesserkade and cannenburghstraat). then you manually look these streets up in a search engine. in our case - Bolnesserkade is marked as being in Ridderkerk and Cannenburghstraat is misspelled. The first one i just ignore (can be added manually later, it's an edge case) the second one i just correct in the source file and make a comment about it.


## AI-generated guide


1. Install QGIS

- Download and install QGIS from the official QGIS website. Follow the installation instructions for your operating system.

2. Obtain Street Data

- You can use OpenStreetMap data, which can be downloaded using tools like Geofabrik or Overpass Turbo.

- For example, in Overpass Turbo:

- Use a query like:

plaintext

       [out:json];
       area[name="City Name"]->.searchArea;
       way"highway";
       out body;
       



- Click "Run" to execute the query and then export the results as GeoJSON or Shapefile.

3. Open QGIS and Load the Data

- Open QGIS.

- To load your street data:

- Go to Layer > Add Layer > Add Vector Layer.

- Select the file you downloaded and click Open.

- Your streets should now appear on the map canvas.

4. Prepare Your List of Streets

- Format your list of street names in a text file (CSV or plain text) or use the list directly within QGIS by creating a new attribute for the streets you want to highlight.

- For example, if you use a CSV file, make sure it has a column with street names.

5. Load Your Street List

- If using a CSV file:

- Go to Layer > Add Layer > Add Delimited Text Layer.

- Choose your CSV file, ensuring the street name column is correctly identified.

- If you want to combine it directly within QGIS, skip this step.

6. Style the Streets

- Open Layer Properties:

- Right-click on the street layer in the Layers panel and choose Properties.

- Change Styling:

- In the Layer Properties window, go to the Symbology tab.

- Change the symbology from Single symbol to Categorized if you want to style by categories (i.e., by street names).

- For basic changes, you can also use Rule-based styling.

- Click Add to create rules or categories.

- If you categorized by street name, match the street names directly to colors.

- For a rule-based approach, you can set conditions based on the street name attribute.

- *Example of Rule-Based Styling*:

- Click on Add Rule.

- For the rule, set the condition (e.g., if the street name equals 'Main St', use a red color).

- Repeat for all streets you want to highlight.

- Click OK to apply the changes.

7. Add Basemap (Optional)

- To add a base map:

- Go to Web > QuickMapServices > Settings.

- Click on Service and add a new service if necessary (e.g., OpenStreetMap).

- After setting it up, use Web > QuickMapServices > OpenStreetMap to add the base map.

8. Export Your Map

- Once you are satisfied with your visualization:

- Go to Project > Import/Export > Export Map to Image or Export Map to PDF.

- Choose your preferred format and set the options as needed.

9. Save Your Project

- Don’t forget to save your QGIS project for future use by going to Project > Save.

Plugins

While you may not necessarily need plugins for basic street coloring, here are a couple that could enhance your experience:

- MMM (Map Multi Measure): For measuring distances or areas on your map.

- OpenLayers Plugin: To add additional background maps (though integrated methods in QGIS are often sufficient).

- QuickMapServices: For easily adding various basemaps (this is already discussed above).

Additional Resources

- QGIS comes with comprehensive documentation here that can be helpful as you get more familiar with the software.

- Tutorials and videos on platforms like YouTube can help visualize some of the above steps.

By following these steps, you should be able to create a customized map in QGIS where specific streets stand out visually according to your requirements.


