Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c8d3905
Add `partition_by` parameter to `GeomTrait::apply_projection`
teunbrand Jun 9, 2026
504d9a3
teunbrand Jun 9, 2026
7324de4
Implement edge densification for line, path, and polygon geoms
teunbrand Jun 9, 2026
a77fcdb
Add tests for needs_projection, densify_edges, and line apply_projection
teunbrand Jun 9, 2026
fdff142
Run cargo fmt and suppress clippy too_many_arguments
teunbrand Jun 9, 2026
401ffaa
Fix NULL coordinates for last vertex in open densified paths
teunbrand Jun 9, 2026
4d94e46
Implement edge densification for tile geom under map projection
teunbrand Jun 10, 2026
ac9b60e
Remove clip parameter from apply_projection signature
teunbrand Jun 10, 2026
65b3348
Add Mappings::insert_column convenience method
teunbrand Jun 10, 2026
da863f7
Add Mappings::column_names and use it across geoms
teunbrand Jun 10, 2026
3f9446c
Implement edge densification for segment geom under map projection
teunbrand Jun 11, 2026
23da848
Implement edge densification for ribbon geom under map projection
teunbrand Jun 11, 2026
a0d18b8
Implement edge densification for rule geom under map projection
teunbrand Jun 12, 2026
c7438a6
block other geoms that have not implemented densification
teunbrand Jun 12, 2026
086dd9a
add comment
teunbrand Jun 12, 2026
63b270a
Unify densification group ID column into naming::DENSIFY_ID_COLUMN
teunbrand Jun 12, 2026
e2632b5
Replace partition_by magic-string checks with typed "densified" param…
teunbrand Jun 12, 2026
7e45ff2
fix double evaluation of window function
teunbrand Jun 12, 2026
3e03c5c
mention projection name
teunbrand Jun 12, 2026
aae1c24
Separate spatial-specific steps from generic densification in rule layer
teunbrand Jun 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ pub fn prepare_data_with_reader(query: &str, reader: &dyn Reader) -> Result<Prep
)?;
}
project.apply_projection_transforms(
&specs[0].layers,
&mut specs[0].layers,
&mut layer_queries,
dialect,
&execute_query,
Expand Down
5 changes: 5 additions & 0 deletions src/naming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ pub const SOURCE_COLUMN: &str = concatcp!(GGSQL_PREFIX, "source", GGSQL_SUFFIX);
/// Alias for schema extraction queries
pub const SCHEMA_ALIAS: &str = concatcp!(GGSQL_SUFFIX, "schema", GGSQL_SUFFIX);

/// Column name for densification group ID.
/// Used by geoms that expand geometry (tile, segment, ribbon, rule) to group
/// densified vertices back into their original feature.
pub const DENSIFY_ID_COLUMN: &str = concatcp!(GGSQL_PREFIX, "densify_id", GGSQL_SUFFIX);

// ============================================================================
// Constructor Functions
// ============================================================================
Expand Down
77 changes: 74 additions & 3 deletions src/plot/layer/geom/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
use super::stat_aggregate;
use super::types::wrap_with_order_by;
use super::{
has_aggregate_param, DefaultAesthetics, DefaultParamValue, GeomTrait, GeomType,
ParamConstraint, ParamDefinition, StatResult,
densify_edges, has_aggregate_param, needs_projection, project_position_columns,
DefaultAesthetics, DefaultParamValue, GeomTrait, GeomType, ParamConstraint, ParamDefinition,
StatResult,
};
use crate::plot::layer::orientation::{ALIGNED, ORIENTATION_VALUES};
use crate::plot::projection::Projection;
use crate::plot::types::DefaultAestheticValue;
use crate::Mappings;
use crate::reader::SqlDialect;
use crate::{naming, Mappings, Result};

/// Line geom - line charts with connected points
#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -77,10 +80,78 @@ impl GeomTrait for Line {
// the Identity and Aggregate paths.
Ok(wrap_with_order_by(query, result, "pos1"))
}

fn apply_projection(
&self,
query: &str,
projection: &Projection,
dialect: &dyn SqlDialect,
mappings: &mut Mappings,
partition_by: &mut Vec<String>,
_parameters: &mut std::collections::HashMap<String, crate::plot::types::ParameterValue>,
) -> Result<String> {
if !needs_projection(projection) {
return Ok(query.to_string());
}
let columns = mappings.column_names();
let pos1_col = naming::aesthetic_column("pos1");
let densified = densify_edges(
query,
dialect,
&columns,
partition_by,
Some(&pos1_col),
false,
1.0,
360,
);
project_position_columns(&densified, projection, dialect, &columns)
}
}

impl std::fmt::Display for Line {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "line")
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::plot::types::ParameterValue;
use crate::reader::AnsiDialect;

#[test]
fn test_apply_projection_densifies_and_transforms() {
let line = Line;
let mut projection = Projection::map();
projection.properties.insert(
"source".to_string(),
ParameterValue::String("EPSG:4326".to_string()),
);
projection.properties.insert(
"target".to_string(),
ParameterValue::String("+proj=ortho +lat_0=0 +lon_0=0".to_string()),
);

let mut mappings = Mappings::new();
mappings.insert_column("pos1", "pos1");
mappings.insert_column("pos2", "pos2");
let result = line
.apply_projection(
"SELECT * FROM t",
&projection,
&AnsiDialect,
&mut mappings,
&mut vec![],
&mut std::collections::HashMap::new(),
)
.unwrap();

// Densification happened
assert!(result.contains("__ggsql_seq__"));
assert!(result.contains("LEAD("));
// Projection happened
assert!(result.contains("ST_Transform"));
}
}
Loading
Loading