NetTopologySuite.IO.GeoJSON icon indicating copy to clipboard operation
NetTopologySuite.IO.GeoJSON copied to clipboard

STJ: Give callers access to the original JsonElement of our IAttributesTable

Open airbreather opened this issue 5 years ago • 1 comments

TryDeserializeJsonObject<T> / TryGetJsonObjectPropertyValue<T> are great, but some advanced use cases would really just love to have the JsonElement to do whatever they want to it.

For example, consider OpenStreetMap: this is an example of geometric data with highly unstructured data associated with each entity.

  • If I store tags as properties in a UTF-8 collated varchar(max) column in a SQL Server 2019 database, I could query them using the database's built-in JSON features.
  • I would still want to map to JsonElement on my EF Core entities.
  • If I want to load from a GeoJSON extract of the data, then I need a JsonElement that represents the IAttributeTable.

The easiest way to do that would be to just return the JsonElement that we already have :grinning:.

airbreather avatar Sep 29 '20 12:09 airbreather

Perhaps it would also be useful if we could allow creating the IAttributesTable from a JsonElement?

Again, a trivial operation, but it could be useful under certain circumstances (data loading from OpenStreetMap comes to mind).

airbreather avatar Sep 30 '20 16:09 airbreather

The easiest way to do that would be to just return the JsonElement that we already have 😀.

This would mean that we add

public interface IAttributesTable<TJson> : IAttributesTable 
{
    TJson RootElement { get; }
}

to NetTopologySuite.Features and make StjAttributesTable implement IAttributesTable<JsonElement>? Or would it be sufficient to declare StjAttributesTable public, perhaps move it up in the namespace?

For the 2nd suggestion we create a factory method, since StjAttributesTable is internal?

FObermaier avatar Nov 22 '22 08:11 FObermaier

The simplest way to do this would be to make StjAttributesTable public and tighten up the design (or at least add xmldoc). I had made it internal when creating it because that's my default for any new types that don't have any specific reasons why they should be part of the public API, but now that there are some, it makes sense to expose it.

I'll try to remember to get to this later today.

airbreather avatar Nov 23 '22 13:11 airbreather

but now that there are some, it makes sense to expose it

makes sense to me, too

DGuidi avatar Nov 23 '22 13:11 DGuidi