Skip to content

Instantly share code, notes, and snippets.

View hugoledoux's full-sized avatar

Hugo Ledoux hugoledoux

View GitHub Profile
@hugoledoux
hugoledoux / schema-stitcher.py
Last active June 19, 2019 12:50
stitch diff JSON schemas into one (in this case CityJSON)
import os
import sys
import json
import jsonschema
import jsonref
root_schema = os.path.abspath('../schemas/cityjson.schema.json')
print (root_schema)
fins = open(root_schema)
@hugoledoux
hugoledoux / mutipolygonwtf.md
Created January 23, 2019 08:32
MultiPolygon can have its Polygons overlapping or edge-adjacent?

MultiPolygon as defined by SFS

from OGC-SFS section 6.1.13.1:

The geometric interiors of any two Surfaces in a MultiSurface may not intersect in the full coordinate system. The boundaries of any two coplanar elements in a MultiSurface may intersect, at most, at a finite number of Points. If they were to meet along a curve, they could be merged into a single surface. MultiSurface is an instantiable class in this Standard, and may be used to represent heterogeneous surfaces collections of polygons and polyhedral surfaces. It defines a set of methods for its subclasses. The subclass of MultiSurface is MultiPolygon corresponding to a collection of Polygons only. Other collections shall use MultiSurface.

OGC-SFS doesn't have a composite type direclty, as ISO and GML have. Although the PolyhedralSurface can be seen as one such case.

fn main() {
let test = vec!["one", "two", "three"];
let index = test.iter().position(|&r| r.to_string() == "two").unwrap();
println!("{}", index);
}
@hugoledoux
hugoledoux / yo.rs
Created February 14, 2019 13:11
testing rust
fn main() {
let test = vec![1, 2, 3];
let index = test.iter().position(|&r| r.to_string() == 2).unwrap();
println!("{}", index);
}
@hugoledoux
hugoledoux / scipy.py
Created May 6, 2019 14:45
speed comparison startin and scipy
from scipy.spatial import Delaunay
import sys
import csv
points = []
with open('/Users/hugo/Dropbox/data/terrains/l2.txt', newline='') as csvfile:
r = csv.reader(csvfile, delimiter=' ', quotechar='|')
@hugoledoux
hugoledoux / matplotlib_poly.py
Created June 25, 2019 13:21
matplotlib polygons quickview
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Polygon
def main():
a = np.arange(8).reshape(4, 2)
a[0][0] = 0.0
a[0][1] = 0.0
@hugoledoux
hugoledoux / Cargo.toml
Last active June 26, 2019 08:58
json schema validation Rust valico
[package]
name = "testvalico"
version = "0.1.0"
authors = ["Hugo Ledoux <[email protected]>"]
edition = "2018"
[dependencies]
valico = "3.0"
serde = "1.0"
serde_json = "1.0"
@hugoledoux
hugoledoux / move_to_origin.py
Created August 15, 2019 10:09
Blender move to origin
from random import random
def move_obj(infile, outfile, translate=(0,0,0), delimiter=' ', standard_building_height=None):
tx,ty,tz = translate
with open(outfile,'w') as fo:
with open(infile,'r') as f:
for i, line in enumerate(f):
if line.startswith('v'):
columns = line.split(delimiter)
@hugoledoux
hugoledoux / cppinstall.md
Last active September 9, 2020 08:44
how to install C++ compiler

NOTE: There are usually many options to set up a development environment on each operating system. What proposed here is not the only option, but I try to minimize your effort. Besides, you may skip some of the steps if they have been properly set up already. Or if you know what you're doing, you're allowed to use any C++ you want. As long as you know how to deal with a CMake project, it's good.

Here's a small test project with one C++ unit (hello.cpp) and a CMake file (the project file to tell the compiler how to compile the project).

Windows

Install Microsoft Visual Studio Community 2019, and not Visual Studio Code.

@hugoledoux
hugoledoux / Cargo.toml
Last active January 21, 2021 19:16
fix wrong "lod" in CityJSON PDOK files
[package]
name = "fixcjpdok"
version = "0.1.0"
authors = ["Hugo Ledoux <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]