Terry vs Ohio....people...this has been through the courts so many times it could be likened to a NY Subway turnstile.
If a policeman sees you committing a crime (even a “minor” one like trespassing) or believes you may be committing that crime, or have just finished committing that crime, that policeman can lawfally stop you.
If that policeman can articulate a legitimate reason to believe you may be concealing a weapon then the officer has a lawful right to pat your outgarments for weapons.
That is a “Terry Stop” or what NY is calling “stop and frisk”.
"Me and my big mouth."