Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 19:15
    ranouf reopened #281
  • Jan 31 2019 19:15
    ranouf commented #281
  • Jan 30 2019 17:14
    ranouf closed #281
  • Jan 30 2019 17:14
    ranouf commented #281
  • Jan 27 2019 11:21
  • Jan 25 2019 08:28
    FObermaier commented #281
  • Jan 25 2019 08:12
    FObermaier labeled #281
  • Jan 25 2019 08:12
    FObermaier commented #281
  • Jan 23 2019 20:53
    ranouf opened #281
  • Jan 21 2019 04:08
  • Jan 19 2019 18:12
    roji commented #233
  • Jan 19 2019 14:19
    YohDeadfall commented #280
  • Jan 19 2019 13:29
    airbreather commented #233
  • Jan 19 2019 13:26
    airbreather commented #233
  • Jan 19 2019 13:26
    airbreather commented #233
  • Jan 19 2019 11:17
    airbreather unlabeled #233
  • Jan 19 2019 11:17
    airbreather unlabeled #280
  • Jan 19 2019 11:17
    airbreather labeled #280
  • Jan 19 2019 11:13
    airbreather opened #280
  • Jan 17 2019 00:41
Felix Obermaier
@FObermaier
You need to union your geometries. NetTopologySuite.Operation.Union.UnionOp is the class you are looking for.
badjo-5
@badjo-5
image.png

One picture speaks more than a hundred words

Thanks a lot!!!!

Bramford Horton
@bramford
How do I create a Circle?
Ah... Nevermind, I found it: NetTopologySuite.Utilities.GeometricShapeFactory.CreateCircle
Adam Schaible
@aschaible
@bramford Did you find a convenient way to generate a circle for use with GPS applications based upon a coordinate and radius distance?
Or … could anyone provide guidance? I feel like this should be simple and I’m missing something obvious. My apologies.
Adam Schaible
@aschaible
I don’t know enough about geospatial - but I could convert distance into decimal degrees and use that I suppose.. but wouldn’t that create an ellipse due to the earth being an imperfect circle? Maybe that’s ‘correct’? Thanks in advance for any information.
Bramford Horton
@bramford
@aschaible Yes, I did. I'll paste some code shortly
@aschaible
var factory = new NetTopologySuite.Utilities.GeometricShapeFactory();
var center = new NetTopologySuite.Geometries.Coordinate(-122.38646, 47.98736);
var topLeft = new NetTopologySuite.Geometries.Coordinate(center.X - 0.01, center.Y + 0.01);
var bottomRight = new NetTopologySuite.Geometries.Coordinate(center.X + 0.01, center.Y - 0.01);
var env = new NetTopologySuite.Geometries.Envelope(topLeft, bottomRight);
factory.Envelope = env;
// Approximated polygon from circle/ellipse
var circle = factory.CreateEllipse();
Bramford Horton
@bramford
To explain, this example takes a point as the "center" and then creates two points to be the top-left and bottom-right corners of a bounding box (aka envelope). The last step is to draw a circle/ellipse that fills the bounding box.
Adam Schaible
@aschaible
@bramford wow nice, thank you!
Stijn Herreman
@stijnherreman
I'm adding IEnumerable<T> support to the shapefile module, but ShapefileDataReader (combining the .dbf and the .shp files) would be an IEnumerable<System.ComponentModel.ICustomTypeDescriptor> or an IEnumerable<NetTopologySuite.IO.RowStructure> if that type is made public. So it's not really an improvement over the current non-generic IEnumerable, the API needs an overhaul. What would be a good way to discuss such an overhaul? Should I make a proposal first?
Stijn Herreman
@stijnherreman
Payoff
@payoff
does anyone know of an OpenApiSchema for Geometry to use with Swagger to better describe schema and example?
with other types, not the one of NTS
tm1k
@tm1k
With NTS, is it possible to interpolate scattered data onto a grid?
Joe Amenta
@airbreather

does anyone know of an OpenApiSchema for Geometry to use with Swagger to better describe schema and example?

@payoff I don't have anything at the moment, but see NetTopologySuite/NetTopologySuite.IO.GeoJSON#68

Björn Harrtell
@bjornharrtell
I've got an interest in reviving DotSpatialAffineCoordinateSequence with a more generic name (PackedAffineCoordinateSequence is my proposal) and with added optional support to point to an offset in the source arrays. It would allow me to work more efficently with my own format FlatGeobuf in C#, and possibly also GDAL bindings. Would this be a welcome addition?
On a similar subject, it looks to me that NetTopologySuite.IO.PostGis works with the default CoordinateArraySequence but could possibly be more efficient if it were to instead use PackedCoordinateSequence which has the same memory layout as PostGIS unless I'm mistaken. I would be interested in making an attempt on that.
Felix Obermaier
@FObermaier
@bjornharrtell thanks for the addition to PostGisReader, which already has been merged.
WRT DotSpatialAffineCoordinateSequence I have no objections deprecating it and replace it with a functionally equivalent sequence/factory. Why would you keep Affine in its name?
Björn Harrtell
@bjornharrtell
@FObermaier: Indicating that the underlying storage is parallel arrays per dimension. But perhaps affine is not a good word for that? Not sure what would be though. PackedCoordinateSequence is already taken by the existing single array backed storage.
Joe Amenta
@airbreather
Technically DotSpatialAffineCoordinateSequence storage is actually a hybrid of SoA and AoS: one array stores data for two dimensions, and each of the other two arrays stores data for just one dimension... I'm not really sure what to call it either.

optional support to point to an offset in the source arrays

If that's important, then perhaps the underlying storage could be Memory<T> / ReadOnlyMemory<T>? These types are more generalized versions of ArraySegment<T> that could be backed by other forms of (contiguous) memory

Joe Amenta
@airbreather

WRT DotSpatialAffineCoordinateSequence I have no objections deprecating it and replace it with a functionally equivalent sequence/factory.

I agree... perhaps the (preferred) layout of data in the sequence could be configurable at the CoordinateSequenceFactory level? Some use cases (like parts of the bulk-optimized methods in ProjNet) want to see x, y, and z as parallel arrays, whereas others (like FlatGeobuf) want to see it laid out like in today's DotSpatialAffineCoordinateSequence with x and y together, but z and m still separate... I'm not sure one way or the other whether or not these should be the same class

Björn Harrtell
@bjornharrtell
@airbreather: I've looked into use of Memory/Span and find it a bit difficult to determine what is best. If a class owns a simple array it can be used with Span which is supposedly more efficient than using Memory?
@airbreather: Agreed there is no obvious good name at all. I don't see how a flexible class can be written with regard to array structure and still be performant.
Joe Amenta
@airbreather
@bjornharrtell Memory<T> has a Span property that gives you the same Span<T> that the simple array would give you. It is, indeed, slightly more efficient to convert a T[] to Span<T> than to convert a Memory<T> to a Span<T>, but it's really not that bad.
Joe Amenta
@airbreather

I don't see how a flexible class can be written with regard to array structure and still be performant.

Considering that using it as an abstract CoordinateSequence, every individual access is a virtual call which can't be inlined... given that, I doubt that it would make a huge difference to have a (Memory<double> array, int ordinateCount)[] to store the underlying data and (int sourceIndex, int offset)[] that tells us where to look in there for each dimension. so the implementation of GetOrdinate would look something like:

public override double GetOrdinate(int index, int ordinateIndex)
{
    var (sourceIndex, offset) = _ordinateLookup[ordinateIndex];
    var (memory, stride) = _underlyingData[sourceIndex];
    return memory.Span[(index * stride) + offset];
}

My intuition is that the performance of this kind of routine will be in the same ballpark as the performance of existing CoordinateSequence implementations.

We could also expose the underlying data (similar to what PackedFooCoordinateSequence.GetRawCoordinates) using something like:

public Memory<double> GetRawData(int ordinateIndex, out int stride)
{
    var (sourceIndex, offset) = _ordinateLookup[ordinateIndex];
    Memory<double> result;
    (result, stride) = _underlyingData[sourceIndex];
    return result.Slice(offset);
}

This underlying data could be used for routines like the bulk methods of ProjNet's MathTransform class / MapProjection class

This is all just speculation, though. I don't have measurements to support either the claim that the abstract version is going to be fast enough for people to use it, or the claim that the GetRawData-style method is going to enable use cases that are compelling enough for people to justify the extra work to contort themselves to use it. i.e., if each ordinate gets its own dedicated array, then you can get full advantage of SIMD for routines that would support it... but routines that don't support SIMD would probably tend to perform worse than when X and Y are packed together because they would pretty much never be in the same cache line.

Björn Harrtell
@bjornharrtell
@airbreather: Agreed there are considerations here that makes the design choice tradeoffs difficult. I did make NetTopologySuite/NetTopologySuite.IO.PostGis#18 to get some measurements on that case though, and it will be even better if I can solve the remaining bugs with the writing part (NetTopologySuite/NetTopologySuite.IO.PostGis#19). I've not worked much with Span/Memory yet and they do seem to be nice and performant abstractions. But if the memory model is paired XY and separated other dimensions which is the memory model I want to target optimization for (Memory<double> array, int ordinateCount)[] is probably not much better than transposing the data for PackedCoordinateSequence? The point of my optimization is avoiding transposing data and even copying the data in the first place.
Joe Amenta
@airbreather

if the memory model is paired XY and separated other dimensions which is the memory model I want to target optimization for (Memory<double> array, int ordinateCount)[] is probably not much better than transposing the data for PackedCoordinateSequence? The point of my optimization is avoiding transposing data and even copying the data in the first place.

This model should support any layout that keeps the underlying values for the coordinates ordered sequentially.

If you have [x0, y0, x1, y1, ..., xn, yn, z0, z1, ..., zn, m0, m1, ..., mn], then this model would look like:

byte[] data = /* ... */
Memory<double> xy = ConvertFrom(data.AsMemory(0, xyLength));
Memory<double> z = ConvertFrom(data.AsMemory(xyLength, zLength));
Memory<double> m = ConvertFrom(data.AsMemory(xyLength + zLength, mLength));

(Memory<double> array, int ordinateCount)[] dataDefinitions =
{
    (xy, 2),
    (z, 1),
    (m, 1),
};

(int sourceIndex, int offset)[] ordinateDefinitions =
{
    (0, 0),
    (0, 1),
    (1, 0),
    (2, 0),
};
return new SparklyCoordinateSequence(dataDefinitions, ordinateDefinitions);

ConvertFrom(Memory<byte>) would probably have to return something backed by a custom MemoryManager<T> implementation in order to make it copy-free, which could have minor performance implications when accessing the values one-by-one, but it shouldn't require any transposing to get into that format.

Björn Harrtell
@bjornharrtell
Ah yes I see it now, clever. 🙂
And we can call it MemoryCoordinateSequence?
Joe Amenta
@airbreather
MemoryCoordinateSequence is fine, CustomizablePackedDoubleCoordinateSequence is longer but perhaps more descriptive
Joe Amenta
@airbreather
#482 opened
Björn Harrtell
@bjornharrtell
Sounds good. But need a strategy for the common layouts, they need to be well known and named to allow for a more optimized path when they are used?
Or perhaps logic can just introspect if two instances are compatible and use optimized path.. but still, would be good with a well known name for what is called DotSpatialAffine today.. but mm, can't come up with a fitting name.
Felix Obermaier
@FObermaier
I like RawCoordinateSequence. For DotSpatialAffine- and PackedCoordinateSequence we have a GetRawCoordinates() function.
CoordinateSequence alone is such a long descriptor, we should keep the rest short.
Björn Harrtell
@bjornharrtell
Agreed RawCoordinateSequence sounds good.
Björn Harrtell
@bjornharrtell
Is DefaultCoordinateSequenceFactory for NtsGeometryServices intentionally get only? It's documented as "Gets or sets the coordiate sequence factory to use".
Felix Obermaier
@FObermaier
Yes, it is get only, but you can set it using the constructor of NtsGeometryServices.
Amirmasoud Ramezani
@Itsamirmasoud
hey guys. i am trying to create a shape file in memory using an overload of ShapefileDataWriter which receives an instance of ShapefileStreamProviderRegistry . when i try to write the features , i get an exception saying that "Memory stream is not expandable."}. now since none of the streams used in the code implements IDisposable i can't use them in a Using statement. i was wondering if anyone has encountered this issue before.
PaulContributor
@PaulContributor
Hello guys, I have a problem with .Net core Entityframework(3.1) & Nettopologysuite.
Deserialization problem "parameterless constructor in Geometry class". I am already using NetTopologySuite.IO.GeoJSON.
Björn Harrtell
@bjornharrtell
I note that WKTReader(GeometryFactory factory) was deprecated in NTS 2.2 but it also seems it changed behaviour so that it will not respect supplied factory any longer, was this intentional?
Joe Amenta
@airbreather

it will not respect supplied factory any longer

It never really did before. v1.15.3, v2.0.0, v2.1.0 all decomposed it the component pieces that it actually used in order to create a new factory on-the-fly, which it did every time. So the misleading constructor was marked obsolete.

I probably should have considered a change to make it start using the provided factory for #502, come to think of it.
Björn Harrtell
@bjornharrtell
@airbreather: hmm but I see completely different behaviour with 2.1 vs 2.2. I have now stopped using it so not something that is a big deal for me but it had me confused for a while.