Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to lutaml-model from shale #7

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ets-gml32"]
path = ets-gml32
path = spec/fixtures/ets-gml32
url = [email protected]:opengeospatial/ets-gml32.git
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 3.0

Expand Down
25 changes: 25 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-08-22 10:41:44 UTC using RuboCop version 1.65.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'ogc-gml.gemspec'

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 30

# Offense count: 323
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
102 changes: 102 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
= OGC GML parser and generator

== Purpose

This library parses and generates GML 3.2 application schemas and data sets that
conform to:

* https://www.iso.org/standard/32554.html[ISO 19136:2007, _Geographic information -- Geography Markup Language_]
* http://portal.opengeospatial.org/files/?artifact_id=20509[OGC 07-036]


== Installation

To install the gem, add the following line to your Gemfile:

[source,ruby]
----
gem 'ogc-gml'
----

And then execute:

[source,bash]
----
$ bundle install
----

== Usage

To use the OGC GML gem in your Ruby project, require it in your code:

[source,ruby]
----
require 'ogc-gml'
----

Then, you can start using the gem's functionality.


For example:

[source,ruby]
----
# Parse a GML file
gml_data = File.read('spec/fixtures/geospatial_jp_iur_3.1/Bridge_class.xml')
gml = Ogc::Gml::Dictionary.from_xml(gml_data)

# Access the loaded GML Dictionary
gml_dictionary = gml.dictionary
gml_dictionary.features.each do |feature|
puts feature.name
end
----

It is possible to utilize the library to develop an Executable Test Suite
for GML, similar to the
http://opengeospatial.github.io/ets-gml32/[OGC ETS for GML 3.2].


== Test suites

The OGC GML gem includes test fixtures from the following sources:

GML dictionary::
From the Cabinet Office, Government Of Japan, i-UR data.
Downloaded from: https://www.chisou.go.jp/tiiki/toshisaisei/itoshisaisei/iur/index.html[here].

GML objects::
Curve, Polygon, Line, Surface, etc. from the test suite of http://opengeospatial.github.io/ets-gml32/[OGC ETS for GML 3.2].



== Contributing

Contributions are welcome! If you find any issues or have suggestions for
improvements, please open an issue or submit a pull request.

== Copyright and license

Copyright Ribose.

The OGC GML gem is released under the MIT License.



// The GML specification defines 10 conformance classes that pertain to application
// schemas. Five of these are currently covered by the test suite:

// * A.1.1: All GML application schemas
// * A.1.4: GML application schemas defining features and feature collections
// * A.1.5: GML application schemas defining spatial geometries
// * A.1.6: GML application schemas defining spatial topologies
// * A.1.7: GML application schemas defining time

// While an instance document is always checked for schema validity, the suite also
// includes tests that validate fundamental GML geometry elements against various
// constraints that cannot be expressed in an XML Schema grammar (e.g. surface boundary
// orientation); these tests also apply to any application-defined geometries that
// can substitute for the base GML geometry.

// Visit the [project documentation website](http://opengeospatial.github.io/ets-gml32/)
// for more information about test suite coverage, including the API documentation.
35 changes: 0 additions & 35 deletions README.md

This file was deleted.

13 changes: 8 additions & 5 deletions lib/ogc/gml.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# frozen_string_literal: true

require "lutaml/model"

Lutaml::Model::Config.configure do |config|
require "lutaml/model/xml_adapter/nokogiri_adapter"
config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
end

require_relative "gml/version"

module Ogc
module Gml
class Error < StandardError; end

# Your code goes here...
end
end

require 'shale'
require 'shale/adapter/nokogiri'
Shale.xml_adapter = Shale::Adapter::Nokogiri

require_relative "gml/abstract_continuous_coverage"
require_relative "gml/abstract_coordinate_operation"
require_relative "gml/abstract_coordinate_system"
Expand Down Expand Up @@ -330,7 +334,6 @@ class Error < StandardError; end
require_relative "gml/value_array"
require_relative "gml/value_property"
require_relative "gml/vector"
require_relative "gml/version"
require_relative "gml/vertical_crs_property"
require_relative "gml/vertical_crs"
require_relative "gml/vertical_cs_property"
Expand Down
3 changes: 1 addition & 2 deletions lib/ogc/gml/abstract_continuous_coverage.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_continuous_coverage_type.rb ---
require "shale"
require "lutaml/model"
require_relative "coverage_function"
require_relative "abstract_coverage"

Expand Down
11 changes: 5 additions & 6 deletions lib/ogc/gml/abstract_coordinate_operation.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_coordinate_operation_type.rb ---
require "shale"
require "lutaml/model"

require_relative "coordinate_operation_accuracy"
require_relative "crs_property"
Expand All @@ -10,10 +9,10 @@
module Ogc
module Gml
class AbstractCoordinateOperation < AbstractTopology
attribute :remarks, Shale::Type::String
attribute :domain_of_validity, Shale::Type::String
attribute :scope, Shale::Type::String, collection: true
attribute :operation_version, Shale::Type::String
attribute :remarks, :string
attribute :domain_of_validity, :string
attribute :scope, :string, collection: true
attribute :operation_version, :string
attribute :coordinate_operation_accuracy, CoordinateOperationAccuracy, collection: true
attribute :source_crs, CRSProperty
attribute :target_crs, CRSProperty
Expand Down
13 changes: 6 additions & 7 deletions lib/ogc/gml/abstract_coordinate_system.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_coordinate_system_type.rb ---
require "shale"
require "lutaml/model"

require_relative "code"
require_relative "code_with_authority"
Expand All @@ -11,15 +10,15 @@

module Ogc
module Gml
class AbstractCoordinateSystem < Shale::Mapper
attribute :id, Shale::Type::Value
attribute :aggregation_type, Shale::Type::String
class AbstractCoordinateSystem < Lutaml::Model::Serializable
attribute :id, :string
attribute :aggregation_type, :string
attribute :meta_data_property, MetaDataProperty, collection: true
attribute :description, Shale::Type::String
attribute :description, :string
attribute :description_reference, Reference
attribute :identifier, CodeWithAuthority
attribute :name, Code, collection: true
attribute :remarks, Shale::Type::String
attribute :remarks, :string
attribute :axis, CoordinateSystemAxisProperty, collection: true

xml do
Expand Down
3 changes: 1 addition & 2 deletions lib/ogc/gml/abstract_coverage.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_coverage_type.rb ---
require "shale"
require "lutaml/model"
require_relative "bounding_shape"
require_relative "domain_set"
require_relative "location_property"
Expand Down
9 changes: 4 additions & 5 deletions lib/ogc/gml/abstract_crs.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_crs_type.rb ---
require "shale"
require "lutaml/model"

require_relative "code"
require_relative "code_with_authority"
Expand All @@ -12,9 +11,9 @@
module Ogc
module Gml
class AbstractCRS < AbstractTopology
attribute :remarks, Shale::Type::String
attribute :domain_of_validity, Shale::Type::String, collection: true
attribute :scope, Shale::Type::String, collection: true
attribute :remarks, :string
attribute :domain_of_validity, :string, collection: true
attribute :scope, :string, collection: true

xml do
root "AbstractSingleCRS"
Expand Down
3 changes: 1 addition & 2 deletions lib/ogc/gml/abstract_curve.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_curve_type.rb ---
require "shale"
require "lutaml/model"
require_relative "abstract_geometric_primitive"

module Ogc
Expand Down
11 changes: 5 additions & 6 deletions lib/ogc/gml/abstract_curve_segment.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# frozen_string_literal: true

# --- abstract_curve_segment_type.rb ---
require "shale"
require "lutaml/model"

module Ogc
module Gml
class AbstractCurveSegment < Shale::Mapper
attribute :num_derivatives_at_start, Shale::Type::Integer#, default: -> { "0" }
attribute :num_derivatives_at_end, Shale::Type::Integer#, default: -> { "0" }
attribute :num_derivative_interior, Shale::Type::Integer#, default: -> { "0" }
class AbstractCurveSegment < Lutaml::Model::Serializable
attribute :num_derivatives_at_start, :integer # , default: -> { "0" }
attribute :num_derivatives_at_end, :integer # , default: -> { "0" }
attribute :num_derivative_interior, :integer # , default: -> { "0" }

xml do
root "AbstractCurveSegment"
Expand Down
11 changes: 5 additions & 6 deletions lib/ogc/gml/abstract_datum.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_datum_type.rb ---
require "shale"
require "lutaml/model"

require_relative "code"
require_relative "code_with_authority"
Expand All @@ -12,11 +11,11 @@
module Ogc
module Gml
class AbstractDatum < AbstractTopology
attribute :remarks, Shale::Type::String
attribute :domain_of_validity, Shale::Type::String
attribute :scope, Shale::Type::String, collection: true
attribute :remarks, :string
attribute :domain_of_validity, :string
attribute :scope, :string, collection: true
attribute :anchor_definition, Code
attribute :realization_epoch, Shale::Type::Date
attribute :realization_epoch, :date

xml do
root "AbstractDatum"
Expand Down
3 changes: 1 addition & 2 deletions lib/ogc/gml/abstract_feature.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_feature_type.rb ---
require "shale"
require "lutaml/model"

require_relative "bounding_shape"
require_relative "code"
Expand Down
3 changes: 1 addition & 2 deletions lib/ogc/gml/abstract_feature_collection.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_feature_collection_type.rb ---
require "shale"
require "lutaml/model"
require_relative "bounding_shape"
require_relative "feature_array_property"
require_relative "feature_property"
Expand Down
9 changes: 4 additions & 5 deletions lib/ogc/gml/abstract_general_conversion.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

# --- abstract_general_conversion_type.rb ---
require "shale"
require "lutaml/model"

require_relative "code"
require_relative "code_with_authority"
Expand All @@ -13,9 +12,9 @@
module Ogc
module Gml
class AbstractGeneralConversion < AbstractTopology
attribute :remarks, Shale::Type::String
attribute :domain_of_validity, Shale::Type::String
attribute :scope, Shale::Type::String, collection: true
attribute :remarks, :string
attribute :domain_of_validity, :string
attribute :scope, :string, collection: true
attribute :coordinate_operation_accuracy, CoordinateOperationAccuracy, collection: true

xml do
Expand Down
Loading
Loading