Ejemplo n.º 1
0
        private void WritePoint(Point point, WKBByteOrder byteOrder, bool writeHeader)
        {
            if (writeHeader)
            {
                // Write byte order
                _writer.Write((byte)byteOrder);

                // Write type
                this.WriteType(point, byteOrder);
            }

            // Write the x coordinate.
            this.Write(point.getX(), byteOrder);

            // Write the y coordinate.
            this.Write(point.getY(), byteOrder);
        }
Ejemplo n.º 2
0
            private void Line(Point point1, Point point2)
            {
                int x1 = point1.getX();
                int y1 = point1.getY();

                int x2 = point2.getX();
                int y2 = point2.getY();

                double m = (y1 - (double)y2) / (x1 - x2);
                double c = y1 - (x1 * m);

                double yIntersect = c;
                double xIntersect = c / -m;

                bool validYIntersect = false;
                bool validXIntersect = false;

                if (y1 < y2) {
                    if (y1 <= yIntersect && yIntersect <= y2) {
                        validYIntersect = true;
                    }
                } else {
                    if (y2 <= yIntersect && yIntersect <= y1) {
                        validYIntersect = true;
                    }
                }

                if (x1 < x2) {
                    if (x1 <= xIntersect && xIntersect <= x2) {
                        validXIntersect = true;
                    }
                } else {
                    if (x2 <= xIntersect && xIntersect <= x1) {
                        validXIntersect = true;
                    }
                }

                if(validYIntersect) {
                    if (yIntersect < 0) {
                        yLessZero++;
                    } else if (0 < yIntersect) {
                        yGreaterZero++;
                    }
                }

                if (validXIntersect) {
                    if (xIntersect < 0) {
                        xLessZero++;
                    } else if (0 < xIntersect) {
                        xGreaterZero++;
                    }
                }
            }