Skip to content

Commit

Permalink
honeybee: Move Wgs84Pos/WebMercatorPos to mvt crate
Browse files Browse the repository at this point in the history
  • Loading branch information
DougLau committed Jan 23, 2024
1 parent 73a6904 commit f7a8af6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 188 deletions.
38 changes: 36 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion honeybee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ base64 = "0.13"
fstr = "0.2"
gift = "0.10"
log = "0.4"
mvt = "0.9"
ntcip = { workspace = true }
pix = "0.13"
pointy = "0.3"
pointy = "0.6"
postgres = "0.19"
postgis = "0.9"
rendzina = { path = "../rendzina" }
Expand Down
174 changes: 0 additions & 174 deletions honeybee/src/geo.rs

This file was deleted.

3 changes: 1 addition & 2 deletions honeybee/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// lib.rs
//
// Copyright (C) 2018-2023 Minnesota Department of Transportation
// Copyright (C) 2018-2024 Minnesota Department of Transportation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -20,7 +20,6 @@ pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
mod base64;
pub mod fetcher;
mod files;
pub mod geo;
mod resource;
mod segments;
mod signmsg;
18 changes: 9 additions & 9 deletions honeybee/src/segments.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// segments.rs
//
// Copyright (C) 2019-2023 Minnesota Department of Transportation
// Copyright (C) 2019-2024 Minnesota Department of Transportation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -14,9 +14,9 @@
//
use crate::fetcher::create_client;
use crate::files::AtomicFile;
use crate::geo::{WebMercatorPos, Wgs84Pos};
use crate::Result;
use pointy::{Float, Pt};
use mvt::{WebMercatorPos, Wgs84Pos};
use pointy::Pt;
use postgis::ewkb::{LineString, Point, Polygon};
use postgres::types::ToSql;
use postgres::{Client, Row, Statement, Transaction};
Expand Down Expand Up @@ -617,13 +617,13 @@ impl<'a> Segments<'a> {
fn create_way(&self, poly: &[(Pt<f64>, Pt<f64>)]) -> Polygon {
let mut points = vec![];
for (vtx, _) in poly {
points.push(Point::new(vtx.x(), vtx.y(), None));
points.push(Point::new(vtx.x, vtx.y, None));
}
for (_, vtx) in poly.iter().rev() {
points.push(Point::new(vtx.x(), vtx.y(), None));
points.push(Point::new(vtx.x, vtx.y, None));
}
if let Some((vtx, _)) = poly.iter().next() {
points.push(Point::new(vtx.x(), vtx.y(), None));
points.push(Point::new(vtx.x, vtx.y, None));
}
let mut linestring = LineString::new();
linestring.points = points;
Expand All @@ -649,7 +649,7 @@ fn road_class_zoom(r_class: i16, zoom: i32) -> bool {
}

/// Create normal vectors for a slice of points
fn create_norms<T: Float>(pts: &[Pt<T>]) -> Vec<Pt<T>> {
fn create_norms(pts: &[Pt<f64>]) -> Vec<Pt<f64>> {
let mut norms = vec![];
for i in 0..pts.len() {
let upstream = vector_upstream(pts, i);
Expand All @@ -666,7 +666,7 @@ fn create_norms<T: Float>(pts: &[Pt<T>]) -> Vec<Pt<T>> {
}

/// Get vector from upstream point to current point
fn vector_upstream<T: Float>(pts: &[Pt<T>], i: usize) -> Option<Pt<T>> {
fn vector_upstream(pts: &[Pt<f64>], i: usize) -> Option<Pt<f64>> {
let current = pts[i];
for up in pts[0..i].iter().rev() {
if *up != current {
Expand All @@ -677,7 +677,7 @@ fn vector_upstream<T: Float>(pts: &[Pt<T>], i: usize) -> Option<Pt<T>> {
}

/// Get vector from current point to downstream point
fn vector_downstream<T: Float>(pts: &[Pt<T>], i: usize) -> Option<Pt<T>> {
fn vector_downstream(pts: &[Pt<f64>], i: usize) -> Option<Pt<f64>> {
let current = pts[i];
for down in pts[i + 1..].iter() {
if *down != current {
Expand Down

0 comments on commit f7a8af6

Please sign in to comment.