Skip to content

Instantly share code, notes, and snippets.

View mschrader15's full-sized avatar

Max Schrader mschrader15

  • University of Alabama
  • Tuscaloosa, Alabama
  • 02:40 (UTC -05:00)
View GitHub Profile
@mschrader15
mschrader15 / DualRingActor.py
Last active March 30, 2022 12:33
Simple Python Class for Controlling NEMA Dual Ring Traffic Lights in SUMO
import copy
import enum
import itertools
from distutils.util import strtobool
from typing import Any, Dict, Iterator, List, OrderedDict, Set, Tuple, Union
from xml.dom import minidom
import json5 as json
import sumolib
import traci
@mschrader15
mschrader15 / logo.css
Created February 3, 2022 18:31
Add Custom Logo to Obsidian Vault
.theme-light .nav-header:before,
.theme-dark .nav-header:before {
font-weight: 700;
font-size: 1.3em;
color: black;
margin-left: auto;
margin-right: auto;
text-align: center;
display: none;
background: url("https://maxschrader.io/logo.svg");
@mschrader15
mschrader15 / _khbit_mac.cpp
Created October 20, 2021 13:55
khbit alternative for MacOS
// From https://cboard.cprogramming.com/c-programming/178177-very-simple-program-impossible-create-mac.html
// May need to clear input buffer between khbit() calls. Use fseek(stdin,0,SEEK_END);
#ifndef GETCH_H_INCLUDED
#define GETCH_H_INCLUDED
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
@mschrader15
mschrader15 / pull_sql_data.py
Created February 23, 2021 16:12
Pull data from a COE sql database
"""
NOTES:
Solves the Microsoft ODBC Driver 17 for SQL Server : SSL Provider ssl_choose_client_version:unsupported protocol
https://askubuntu.com/questions/1284658/how-to-fix-microsoft-odbc-driver-17-for-sql-server-ssl-provider-ssl-choose-cli
"""
import csv
import os
import sys
from configparser import ConfigParser
from datetime import datetime, timedelta
@mschrader15
mschrader15 / parse_emissions_xml.py
Created January 7, 2021 18:12
Sumo Emissions Output File Processing
from lxml import etree
import numpy as np
import pandas as pd
import time
import csv
def parse_detector_xml(file_path, save_path):
fields = ['interval_begin', 'interval_end', 'interval_flow', 'interval_harmonicMeanSpeed', 'interval_id',
'interval_length', 'interval_nVehContrib', 'interval_nVehEntered', 'interval_occupancy', 'interval_meanSpeed']
@mschrader15
mschrader15 / yaxis_aligner.py
Last active July 3, 2020 00:03
A python module to align Plotly Y-axes. Based on: https://github.com/VictorBezak/Plotly_Multi-Axes_Gridlines
import math
class CalculateTicks:
def __init__(self, data, tick_num):
self.negative = False
self.y_negative_ratio = None
self.y_positive_ratio = None
self.y_range_min = None

How to Geo-Locate a SUMO Network

1. Understanding the location information in the *.net.xml file

At the top of the .net.xml file, there is an xml element that looks like either:

<location netOffset="0.00,0.00" convBoundary="-355.14,-1108.16,393.23,944.28" origBoundary="-10000000000.00,-10000000000.00,10000000000.00,10000000000.00" projParameter="!"/>

or in a geo-located network: