GEOS Coding Patterns

This page documents coding patterns followed in the GEOS codebase.

The patterns are intended to improve: understandability, consistency, performance, and memory safety.

Code should follow the patterns given here, unless this is not possible for compatibility reasons. Older GEOS code may not adhere to all patterns, but the goal is to update it when possible.


Object References

  • Return created objects using std::unique_ptr<Object>
  • To take ownership of a returned object use std::unique_ptr<Object>

To Be Investigated

Geometry Factory improvements

  • Add createXX methods returning std::unique_ptr<XX>
  • Remove old create methods once all code is switched to using std::unique_ptr

Unique_ptr typedefs?

  • To reduce boilerplate perhaps define typedefs for common types: UP_Geometry, UP_CoordinateSequence, etc

Coordinate Sequence improvements


  • Improve performance by avoiding virtual function calls
  • Support immutable use of external coordinate sequence formats


  • Virtual functions
    • Are they really a performance hit?
    • Use templates?


  • Remove mutating methods where not strictly needed
  • Mark non-mutating methods as const to allow immutable use of external coordinate sequence formats
    • Will this work?
Last modified 5 years ago Last modified on May 15, 2019, 12:29:08 PM
Note: See TracWiki for help on using the wiki.