com.twitter.hbc.core.endpoint.Location.Coordinate Java Examples

The following examples show how to use com.twitter.hbc.core.endpoint.Location.Coordinate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetTwitter.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ValidationResult validate(final String subject, final String input, final ValidationContext context) {
    try {
        final List<Location> locations = LocationUtil.parseLocations(input);
        for (final Location location : locations) {
            final Coordinate sw = location.southwestCoordinate();
            final Coordinate ne = location.northeastCoordinate();

            if (sw.longitude() > ne.longitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Longitude (" + sw.longitude() + ") must be less than NE Longitude ("
                                + ne.longitude() + ").").build();
            }

            if (sw.longitude() == ne.longitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Longitude (" + sw.longitude() + ") can not be equal to NE Longitude ("
                                + ne.longitude() + ").").build();
            }

            if (sw.latitude() > ne.latitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Latitude (" + sw.latitude() + ") must be less than NE Latitude ("
                                + ne.latitude() + ").").build();
            }

            if (sw.latitude() == ne.latitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Latitude (" + sw.latitude() + ") can not be equal to NE Latitude ("
                                + ne.latitude() + ").").build();
            }
        }

        return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();

    } catch (IllegalStateException e) {
        return new ValidationResult.Builder()
                .input(input).subject(subject).valid(false)
                .explanation("Must be a comma-separated list of longitude,latitude pairs specifying one or more bounding boxes.")
                .build();
    }
}
 
Example #2
Source File: GetTwitter.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ValidationResult validate(final String subject, final String input, final ValidationContext context) {
    try {
        final List<Location> locations = LocationUtil.parseLocations(input);
        for (final Location location : locations) {
            final Coordinate sw = location.southwestCoordinate();
            final Coordinate ne = location.northeastCoordinate();

            if (sw.longitude() > ne.longitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Longitude (" + sw.longitude() + ") must be less than NE Longitude ("
                                + ne.longitude() + ").").build();
            }

            if (sw.longitude() == ne.longitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Longitude (" + sw.longitude() + ") can not be equal to NE Longitude ("
                                + ne.longitude() + ").").build();
            }

            if (sw.latitude() > ne.latitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Latitude (" + sw.latitude() + ") must be less than NE Latitude ("
                                + ne.latitude() + ").").build();
            }

            if (sw.latitude() == ne.latitude()) {
                return new ValidationResult.Builder().input(input).subject(subject).valid(false)
                        .explanation("SW Latitude (" + sw.latitude() + ") can not be equal to NE Latitude ("
                                + ne.latitude() + ").").build();
            }
        }

        return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();

    } catch (IllegalStateException e) {
        return new ValidationResult.Builder()
                .input(input).subject(subject).valid(false)
                .explanation("Must be a comma-separated list of longitude,latitude pairs specifying one or more bounding boxes.")
                .build();
    }
}