1
- How It Works:
User’s GPS latitude must be between -22.899529 and -22.899922 so that if brood one perimeter. The app will only work some features if you are within this perimeter
.
- Observing:
1) I didn’t insert the longitude because I’m trying to make it enter this If, but I’m having a hard time, in case possible please show examples with longitude together.
- Shopping mall.java
package com.vuforia.samples.Books.app.Neoris; import android.app.Activity; import com.vuforia.Vuforia; import com.vuforia.samples.Books.ui.ActivityList.AboutScreen; /** * Created by th on 14/06/17. */ public class Shopping { private String nomeShopping; private String licenseKey; private String accessKey; private String secretKey; private Activity mActivity; private int mVuforiaFlags = 0; public Shopping(AboutScreen aboutScreen) { } public Shopping() { } public String getNome() { return nomeShopping; } public void setNome(String nome) { this.nomeShopping = nome; } public String getLicenseKey() { return licenseKey; } public void setLicenseKey(String licenseKey) { this.licenseKey = licenseKey; } public String getAccessKey() { return accessKey; } public void setAccessKey(String accessKey) { this.accessKey = accessKey; } public String getSecretKey() { return secretKey; } public void setSecretKey(String secretKey) { this.secretKey = secretKey; } public void setDados(double latitude, double longitude){ // -22.899529 -22.899922 // O menor é o MAIOR // o maior é o MENOR if((latitude >= -22.899529 && latitude <= -22.899922)){ setNome("Neoris"); setLicenseKey("Ad84Z0z/////AAAAGSgcOhPVvkoniWypHW2Dfsw+iX69sih5qx5JH1PEs92sM2xIhbsKnb2eTNkfBeQymsfgyRswpCDi2Ocu78RH+5+7/fXED7hJPLf3T7k4xKKLl4z8OKfCmr8jE0L5wQdJVV9L3tiHEoUx67M4b3ZSlO3/AzDLYi2/Zt3z8fuPo62osy469O+bKBsKKZtnyX9K7RYwJ2colMQ1bIhQERjg1w5cEZLHUacXAI1ndYhzS2Xl5iwAz98VZ65sptn+PrA5Xno55VGddt7rSBmvwuhZzeyShWnOqiYFhjWg80F3PFv2H/hYfIt4ML37yerJxS/n0z8yFv1H5gPi+Abd5nfaboz/xx1WgXf0yDvQKslFV+rr"); Vuforia.setInitParameters(mActivity, mVuforiaFlags, "" + getLicenseKey()); // Importante para o setLicenseKey. setAccessKey("f854427b00cf89cb4909cf3780a22f1fe6dd1daa"); setSecretKey("16208b50224e2ff8d3c93f069d2c4adf739cea7a"); } else if((latitude >= -22.899682) && (latitude <= -22.900006) && (longitude >= -43.178666) && (longitude <= -43.178197)){ setNome("Outros"); setLicenseKey("AULCxLD/////AAAAGa6JoRhAAk70lshljOUpGeN7XUgbJ/jA8ZGpdHb4EVUBTsJ5Z6C8FYvrRBtMsbePU6wI2DKgO3U7msQ9bMqY1+qn0SRY8K3raNYxd+cgBkbmiJDonnuvPr9Hd3RHo7ArwO1x8wGsA1sWw/Bo+q7HpjLbdKqM/ceI2IlnWJQTD+H47zlFuV63utnK/soPttLP+HmL1Lx/ko6uLLKe9yhuuAwpbkNR0UsNGYXlueTCOU/CfIot0VCBg2Kxpz4/cnlmCetedW0+bZypzh6gWfV9MS1Sh9n1LEYr8EXjpOEyHhaBPAgE3lX5khkVc3FRetD81WC7fRAQB5ozp6X1H4u04yWLbzWf8S8XSPK5a542gbNg"); Vuforia.setInitParameters(mActivity, mVuforiaFlags, "" + getLicenseKey()); // Importante para o setLicenseKey. setAccessKey("6ad29c13cb8af364c7c7f893ca7651974a887f96"); setSecretKey("370db33ce57acc73a84df1f6d19339da69e45235"); } } }
- Aboutscreen.java [The code is not complete because it does not need]:
latitude = gps.getLatitude(); longitude = gps.getLongitude(); /* * Melhora a precisão do Resultado encontrado pelo GPS * para (6) casas decimais com arredondamento. * */ BigDecimal precisaoLatitude = new BigDecimal(latitude); BigDecimal precisaoLongitude = new BigDecimal(longitude); precisaoLatitude = precisaoLatitude.setScale(6, RoundingMode.UP); precisaoLongitude = precisaoLongitude.setScale(6, RoundingMode.UP); latitude = Double.parseDouble(String.valueOf(precisaoLatitude)); longitude = Double.parseDouble(String.valueOf(precisaoLongitude));
But look at my reasoning. -22.899529 is a number greater than -22.89992, as this first number is closer to being positive than the other, correct? So it can’t be <= -22.899529 and not >= -22.89992. Or I’m wrong?
– Thiago Saad
It is wrong. You want the position to be between 2 values: -xx.xxx920 and -xx.xxx529, so it must be greater than -xx.xxx920 and less than -xx.xxx529.
– Márcio Oliveira
But then @Thiagosaad, that’s what I answered, latitude <= -22.899529 && latitude >= -22.89992. Its latitude >= -22.899529 && latitude <= -22.89992.
– Victor Pettengill Fernandes
@Victorpettengillfernandes, he does not enter the if.. I read the API and says to use the Location.distanceBetween , but it only calculates (Latitude of the User, Longitude of the User, latitude origin, latitude destination). I need him to calculate 2 LAT and 2 LONG+ the user’s LAT and LONG comparison.
– Thiago Saad
@Márciooliveira Victor’s answer is correct. As it is negative number, for numbers before the -22.89992 are even bigger.
– Grupo CDS Informática
I said "It’s wrong" to the above comment of mine.
– Márcio Oliveira