public void DegeneratePolygons() { var polygon = new double[][][] { new double[][] { new double[] { 0, 0 }, new double[] { 1, 0 }, new double[] { 2, 0 }, new double[] { 0, 0 } } }; var polylabel = Polylabel.GetPolylabel(polygon); Assert.Equal(new double[] { 0, 0 }, polylabel); polygon = new double[][][] { new double[][] { new double[] { 0, 0 }, new double[] { 1, 0 }, new double[] { 1, 1 }, new double[] { 1, 0 }, new double[] { 0, 0 } } }; polylabel = Polylabel.GetPolylabel(polygon); Assert.Equal(new double[] { 0, 0 }, polylabel); }
public void PolylabelJson(string fileName, double expectedX, double expectedY) { var jsonString = File.ReadAllText(fileName); var polygon = JsonConvert.DeserializeObject <double[][][]>(jsonString); var center = Polylabel.GetPolylabel(polygon, debug: true); Assert.Equal(expectedX, center[0]); Assert.Equal(expectedY, center[1]); }