Comments (2)
One way to deal with this (probably a breaking change) could be to use NetTopologySuite.Features
to hold the ID, which would also support other things that get added to the spec in the future.
To avoid breaking things that work today, we could add a new event on TinyWkbReader
and a new event on TinyWkbWriter
that the user can subscribe to in order to tell us how to translate between UserData
and the long
that we read / generate.
Using that event when reading geometries:
GeometryCollection gc = /* ... */;
long[] idList = /* ... */;
EventHandler<EventArgsSubclass> handler = this.TheNewEvent;
if (handler != null)
{
EventArgsSubclass args = new EventArgsSubclass(gc, idList);
handler(this, args);
}
else
{
for (int i = 0; i < gc.NumGeometries; i++)
{
gc.GetGeometryN(i).UserData = idList[i];
}
}
Using that event when writing geometries:
BinaryWriter writer = /* ... */;
GeometryCollection gc = /* ... */;
EventHandler<EventArgsSubclass> handler = this.TheNewEvent;
long[] idList;
if (handler != null)
{
EventArgsSubclass args = new EventArgsSubclass(gc);
handler(this, args);
idList = args.IdList.ToArray();
}
else
{
idList = new long[gc.Count];
bool fallback = false;
for (int i = 0; i < idList.Length; i++)
{
object userData = gc.GetGeometryN(i).UserData;
if (userData is null)
{
fallback = true;
break;
}
try
{
idList[i] = Convert.ToInt64(userData, CultureInfo.InvariantCulture);
}
catch
{
fallback = true;
break;
}
}
if (fallback)
{
for (int i = 0; i < idList.Length; i++)
{
idList[i] = GetNextId();
}
}
}
We'd keep the exact same behavior by default, but the user could then tell us how they want to store their own IDs and we would honor that.
from nettopologysuite.io.tinywkb.
Note:
- This project is not that old.
- The download numbers on NuGet are not that high, too.
I'm not too concerned about breaking backward compatibility, so if there is a different approach to handle this that you actually favor, then I don't have a problem with it.
from nettopologysuite.io.tinywkb.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nettopologysuite.io.tinywkb.