com.google.type.LatLng Java Examples
The following examples show how to use
com.google.type.LatLng.
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: NewEnrichmentItemFactory.java From java-photoslibrary with Apache License 2.0 | 6 votes |
/** * Creates a {@link NewEnrichmentItem} with a {@link LocationEnrichment}. * * @throws IllegalArgumentException Thrown if the location name is null or empty. */ public static final NewEnrichmentItem createLocationEnrichment( String locationName, double latitude, double longitude) { if (locationName == null || locationName.isEmpty()) { throw new IllegalArgumentException("Location name cannot be null or empty."); } return NewEnrichmentItem.newBuilder() .setLocationEnrichment( LocationEnrichment.newBuilder() .setLocation( Location.newBuilder() .setLocationName(locationName) .setLatlng( LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude)))) .build(); }
Example #2
Source File: Values.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
private static int compareGeoPoints(LatLng left, LatLng right) { int comparison = Util.compareDoubles(left.getLatitude(), right.getLatitude()); if (comparison == 0) { return Util.compareDoubles(left.getLongitude(), right.getLongitude()); } return comparison; }
Example #3
Source File: RemoteSerializerTest.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
@Test public void testEncodesGeoPoints() { Value geoPoint = wrap(new GeoPoint(1.23, 4.56)); Value.Builder proto = Value.newBuilder(); proto.setGeoPointValue(LatLng.newBuilder().setLatitude(1.23).setLongitude(4.56)); assertRoundTrip(geoPoint, proto.build(), Value.ValueTypeCase.GEO_POINT_VALUE); }
Example #4
Source File: NewEnrichmentItemFactory.java From java-photoslibrary with Apache License 2.0 | 5 votes |
/** * Creates a {@link NewEnrichmentItem} with a {@link MapEnrichment}. * * @throws IllegalArgumentException Thrown if the origin or destination location names are either * null or empty. */ public static final NewEnrichmentItem createMapEnrichment( String originLocationName, double originLatitude, double originLongitude, String destinationLocationName, double destinationLatitude, double destinationLongitude) { if (originLocationName == null || originLocationName.isEmpty()) { throw new IllegalArgumentException("Origin location name cannot be null or empty."); } if (destinationLocationName == null || destinationLocationName.isEmpty()) { throw new IllegalArgumentException("Destination location name cannot be null or empty."); } Location.Builder originLocation = Location.newBuilder() .setLocationName(originLocationName) .setLatlng( LatLng.newBuilder().setLatitude(originLatitude).setLongitude(originLongitude)); Location.Builder destinationLocation = Location.newBuilder() .setLocationName(destinationLocationName) .setLatlng( LatLng.newBuilder() .setLatitude(destinationLatitude) .setLongitude(destinationLongitude)); return NewEnrichmentItem.newBuilder() .setMapEnrichment( MapEnrichment.newBuilder() .setOrigin(originLocation) .setDestination(destinationLocation)) .build(); }
Example #5
Source File: Values.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
private static void canonifyGeoPoint(StringBuilder builder, LatLng latLng) { builder.append(String.format("geo(%s,%s)", latLng.getLatitude(), latLng.getLongitude())); }
Example #6
Source File: CommuteSearchJobs.java From java-docs-samples with Apache License 2.0 | 4 votes |
public static void searchJobs(String projectId, String tenantId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); String domain = "www.example.com"; String sessionId = "Hashed session identifier"; String userId = "Hashed user identifier"; RequestMetadata requestMetadata = RequestMetadata.newBuilder() .setDomain(domain) .setSessionId(sessionId) .setUserId(userId) .build(); CommuteMethod commuteMethod = CommuteMethod.DRIVING; long seconds = 3600L; Duration travelDuration = Duration.newBuilder().setSeconds(seconds).build(); double latitude = 37.422408; double longitude = -122.084068; LatLng startCoordinates = LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build(); CommuteFilter commuteFilter = CommuteFilter.newBuilder() .setCommuteMethod(commuteMethod) .setTravelDuration(travelDuration) .setStartCoordinates(startCoordinates) .build(); JobQuery jobQuery = JobQuery.newBuilder().setCommuteFilter(commuteFilter).build(); SearchJobsRequest request = SearchJobsRequest.newBuilder() .setParent(parent.toString()) .setRequestMetadata(requestMetadata) .setJobQuery(jobQuery) .build(); for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { System.out.format("Job summary: %s%n", responseItem.getJobSummary()); System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); System.out.format("Job name: %s%n", job.getName()); System.out.format("Job title: %s%n", job.getTitle()); } } }
Example #7
Source File: DatastoreHelper.java From google-cloud-datastore with Apache License 2.0 | 4 votes |
/** * Makes a GeoPoint value. */ public static Value.Builder makeValue(LatLng value) { return Value.newBuilder().setGeoPointValue(value); }
Example #8
Source File: DatastoreHelper.java From google-cloud-datastore with Apache License 2.0 | 4 votes |
/** * Makes a GeoPoint value. */ public static Value.Builder makeValue(LatLng.Builder value) { return makeValue(value.build()); }