<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.spatial4j.core.shape.impl;

import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.distance.DistanceUtils;
import com.spatial4j.core.shape.Point;
import com.spatial4j.core.shape.Rectangle;
import com.spatial4j.core.shape.Shape;
import com.spatial4j.core.shape.SpatialRelation;

import static com.spatial4j.core.shape.SpatialRelation.CONTAINS;
import static com.spatial4j.core.shape.SpatialRelation.DISJOINT;
import static com.spatial4j.core.shape.SpatialRelation.INTERSECTS;
import static com.spatial4j.core.shape.SpatialRelation.WITHIN;


public class GeoBufferedLine implements Shape {

  private final Point a;
  private final Point b;
  private final double buffer;
  private final double bufferPerp;
  private final SpatialContext ctx;

  @Override
  public Rectangle getBoundingBox() {

    double minX, maxX;
    double minY, maxY;

    if(a.getX() > a.getY()) {
      maxX = a.getX();
      minX = b.getX();
    } else {
      maxX = b.getX();
      minX = a.getX();
    }

    if(a.getY() > b.getY()) {
      maxY = a.getY();
      minY = b.getY();
    } else {
      maxY = b.getY();
      minY = a.getY();
    }

    Point highestPoint = linePrimary.highestPoint(ctx);
    Point lowestPoint = linePrimary.lowestPoint(ctx);

    

    return null;

  }

  @Override
  public boolean hasArea() {
    return false;
  }

  @Override
  public double getArea(SpatialContext ctx) {
    return 0;
  }

  @Override<commit_msg>Bounding Box, still needs testing.<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.spatial4j.core.shape.impl;

import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.distance.DistanceUtils;
import com.spatial4j.core.shape.Point;
import com.spatial4j.core.shape.Rectangle;
import com.spatial4j.core.shape.Shape;
import com.spatial4j.core.shape.SpatialRelation;

import static com.spatial4j.core.shape.SpatialRelation.CONTAINS;
import static com.spatial4j.core.shape.SpatialRelation.DISJOINT;
import static com.spatial4j.core.shape.SpatialRelation.INTERSECTS;
import static com.spatial4j.core.shape.SpatialRelation.WITHIN;


public class GeoBufferedLine implements Shape {

  private final Point a;
  private final Point b;
  private final double buffer;
  private final double bufferPerp;
  private final SpatialContext ctx;


  // does not include the bounding box.
  @Override
  public Rectangle getBoundingBox() {

    double minX, maxX;
    double minY, maxY;

    if(a.getX() > a.getY()) {
      maxX = a.getX();
      minX = b.getX();
    } else {
      maxX = b.getX();
      minX = a.getX();
    }

    if(a.getY() > b.getY()) {
      maxY = a.getY();
      minY = b.getY();
    } else {
      maxY = b.getY();
      minY = a.getY();
    }

    Point highestPoint = linePrimary.highestPoint(ctx);
    Point lowestPoint = linePrimary.lowestPoint(ctx);

    // TODO: find which direction is the shortest, between the two points.
    // Find the Change in x, and y. Try both, see which is shorter.
    // Ie, calc delta x, add to one point, subtract x from the same point, see which one,
    // gives us the same

    boolean posXDirection = ((maxX - minX) == 0 ) ? true : false;
    boolean posYDirection = ((maxY - minY) == 0 ) ? true : false;

    // Moving from minx to maxx (Positive long)
    if(posXDirection) {
      if((maxY >= 0) && (minX < highestPoint.getX()) && (highestPoint.getX() < maxX)) {
        maxY = highestPoint.getY();
      }

      if(((maxY <= 0) && (minX < lowestPoint.getX()) && (lowestPoint.getX() < maxX))) {
        minY = lowestPoint.getY();
      }
    } else {
      if((maxY >= 0) && (minX > highestPoint.getX()) && (highestPoint.getX() > maxX)) {
        maxY = highestPoint.getY();
      }

      if(((maxY <= 0) && (minX > lowestPoint.getX()) && (lowestPoint.getX() > maxX))) {
        minY = lowestPoint.getY();
      }
    }

    return ctx.makeRectangle(minX + buffer,maxX + buffer,minY + buffer,maxY + buffer);
  }

  @Override
  public boolean hasArea() {
    return false;
  }

  @Override
  public double getArea(SpatialContext ctx) {
    return 0;
  }

  @Override
{'fraction_non_alphanumeric': 0.10767609344809415, 'fraction_numerical': 0.006674863867907957, 'mean_word_length': 3.236607142857143, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3227470', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1773, 'n_words': 549}